A query is broken up into terms and operators. There are two types of terms: Single Terms and Phrases.
A Single Term is a single word such as test or hello
A Phrase is a group of words surrounded by double quotes such as "hello dolly".
Multiple terms can be combined together with Boolean operators to form a more complex query (see below).
The search api includes the concept of a Query Profile. Each index has a default profile that is applied to unfielded queries. For example, Store A's default index may include Fields named title and publisher. It is possible to for queries to address these fields directly like so:
This query will search for the value "sleep" in title field and the value "vintage" in publisher field. Unfielded terms can be directed at the index fields according to the default query profile. So, in the previous example, the default profile may include both title and publisher fields. In this case, a search like:
would equate to one like this:
title:sleep title:vintage publisher:sleep publisher:
A field is only valid for the term that it directly precedes, so the query
Will only find "Big" in the title field. It will use the query profile to determine how to direct the other terms in the query. In the example above, this would resolve to a query like:
title:Big title:Sleep publisher:Sleep
The query syntax currently supports both multiple and single character wildcard searches.
To perform a single character wildcard search use the "?" symbol.
To perform a multiple character wildcard search use the "*" symbol.
The single character wildcard search looks for terms that match that with the single character replaced. For example, to search for "text" or "test" you can use the search:
Multiple character wildcard searches looks for 0 or more characters. For example, to search for test, tests or tester, you can use the search:
You can also use the wildcard searches in the middle of a term.
Note: You cannot use a * or ? symbol as the first character of a term. In addition, placing a wildcard too close to the start of a term may result in an a query error due to the current implementation of wildcard searches. If this happens, and where possible, make your query more specific by moving the wildcard further down the term.
Boolean operators allow terms to be combined. AND, "&&", "+", OR, "||", NOT and "-" are supported as Boolean operators.
title:"The Big Sleep" OR publisher:vintage
is equivalent to
publisher:vintage || title:"The Big Sleep"
AND is the default conjunction operator, meaning that queries with multiple terms are AND queries by default. The symbol && can be used in place of the word AND.
title:sleep AND author:Chandler
is equivalent to
title:sleep && author:Chandler
The "+" or required operator requires that the term after the "+" symbol exist somewhere
For example the query:
searches for items where the title must contain the term "big" and may contain the term "sleep"
The NOT operator excludes items that contain the term after NOT. The symbol ! can be used in place of the word NOT.
title:sleep NOT author:nolan
searches for items with the term "sleep" in the title field, excluding items with the term "nolan" in the author field
Note: The NOT operator cannot be used with just one term. For example, the following search will return no results:
The "-" can also be used to exclude items that contain the term after the "-" symbol.
To search for items that contain (according to the store's default query profile) "sleep" but not "sharks" use the query:
Query clauses can be grouped in order to control boolean logic and form sub queries.
(sleep OR goodbye) AND chandler
The current list of characters which require escaping is:
+ - && || ! ( ) " * ? : \
To escape these characters use the \ before the character. For example to search for http://example.com/things?id=foo:bar use the query: