Shopify API search syntax
This page provides information on the syntax for searching text fields.
The same search query syntax is used across Shopify as an interface to search functionality. This includes the storefront, admin, mobile apps, customer group queries, Admin API, and Storefront API. For the APIs, the specific resources that can be queried are defined in the reference documentation.
Search query grammar overviewAnchor link to section titled "Search query grammar overview"
A string query is a text search made up of terms, connectives, modifiers, and comparators. The search grammar rules defined here can be built into larger structures as defined by the search query syntax.
The search grammar is expressed similarly to EBNF and uses the following baseline terminal symbols:
||Any sequence of space, tab, or newline characters.|
||Any sequence of non-whitespace, non-special characters. For more information, refer to Special characters.|
||Any name, or any quoted string (single or double quotes are both permitted). Date values must be a string surrounded by quotes.|
A query is one or more terms separated by whitespace and optionally by single connectives. A query may have optional leading and trailing whitespace.
ConnectivesAnchor link to section titled "Connectives"
When a connective is not specified between two terms,
AND is implied.
query=state:enabled OR state:disabled
A term consists of an optional modifier, followed either by a subquery (enclosed in parentheses) or a value with an optional name-and-comparator.
query=-first_name:Bob AND orders_count:>3 orders_count:<=4
Supported modifiers are
- with no following whitespace, or
NOT followed by whitespace. Both mean the same thing.
ComparatorsAnchor link to section titled "Comparators"
The following comparators are supported for search queries:
Special charactersAnchor link to section titled "Special characters"
Special characters serve specific functions in search query syntax and need to be escaped with a backslash. For example,
: \ ( ).
Names can include the characters
" but can't start with them. Names can include escaped characters using backslash escaping.
Search query syntaxAnchor link to section titled "Search query syntax"
Shopify search query syntax is based on the defined grammar and enables the following search behavior. The following table describes the different types of search queries and their syntax:
|Type||Description||Example syntax||Example explained|
|Term search||A case-insensitive search of all the fields in a document.||
||A case-insensitive search for both "bob" AND "norman".|
|Field search||A search that applies to terms in specific fields.||
||A search for "Bob" in the
The value must immediately follow the field with no whitespace.
|Range search||A search that specifies a range of values to search against. Supported operators:
||A search that matches documents where the
|NOT query||A search that excludes documents that include the specified value.
The NOT operator must be capitalized to execute a NOT query, and only applies to the specified space-separated term or query.
||Searches that exclude documents that include the term "bob".|
|Boolean operators||A search that allow terms to be combined through logic operators.||
|Grouping||A search using parentheses to group clauses to form subqueries.||
||A search for disabled customers with "sale shopper" or "VIP" tags.|
|Phrase query||A search for a group of words surrounded by double quotes.||
||A search for the term "bob" followed immediately by the term "norman" in the
|Prefix query||A search that matches documents containing terms that begin with a specified set of characters. Shopify supports RE2 syntax for regular expressions.||
||A search for all the terms that begin with the prefix "norm", such as "norman".|
|Exists query||A search that matches documents with a non-null value in the specified field. Shopify supports RE2 syntax for regular expressions.||
||A search for non-null values in the
The query can be combined with a NOT query to find fields missing a value. For example,
This section provides examples of how you can use the Shopify API search syntax.
Using Anchor link to section titled "Using created_at"
List 5 products that were added to a store on October 21st, 2020.
Using Anchor link to section titled "Using title"
List 5 products with the name "Caramel Apple".
List 10 products that include terms that begin with the prefix
head, such as
Using Anchor link to section titled "Using OR and a range"
OR and a range
List 5 products with the name "Caramel Apple", or products that have an inventory of over 500 items and less than or equal to 1000 items.