Full-Text Query Syntax

Mobile SDK full-text queries use SQLite's enhanced query syntax. With this syntax, you can use logical operators to refine your search.

The following table shows the syntactical options that Mobile SDK queries support. Following the table are keyed examples of the various query styles and sample output. For more information, see Sections 3.1, “Full-text Index Queries,” and 3.2, “Set Operations Using The Enhanced Query Syntax,” at sqlite.org.

Query OptionSmartStore BehaviorRelated Examples
Specify one or more full-text indexed pathsPerforms match against values only at the paths you defined.

g, h, i, j, and k

Set the path to a null valuePerforms match against all full-text indexed paths

Note: If your path is null, you can still specify a target field in the matchKey argument. Use this format: {soupName:path}:term

a,b,c,d,e, and f

Specify more than one term without operators or groupingAssumes an “AND” between termsb and h
Place a star at the end of a termMatches rows containing words that start with the query termd and j
Use “OR” between termsFinds one or both termsc and i
Use the unary “NOT” operator before a termIgnores rows that contain that terme, f, and k
Specify a phrase search by placing multiple terms within double quotes (“ ”).Returns soup elements in which the entire phrase occurs in one or more full-text indexed fields 

For these examples, a soup named “animals” contains the following records. The name and color fields are indexed as full_text.

ExamplePathMatch KeySelects...Records Returned
a.null“black”Records containing the word “black” in any full-text indexed field1, 3
b.null“black cat”Records containing the words “black” and “cat” in any full-text indexed field1
c.null“black OR cat”Records containing either the word “black” or the word “cat” in any full-text indexed field1, 2, 3
d.null“b*”Records containing a word starting with “b” in any full-text indexed field1, 3
e.null“black NOT cat”Records containing the word “black” but not the word “cat” in any full-text indexed field3
f.null“{animals} NOT cat”Records containing the word “black” in the color field and not having the word “cat” in any full-text indexed field3
g.“color”“black”Records containing the word “black” in the color field1, 3
h.“color”“black cat”Records containing the words “black” and “cat” in the color fieldNo records
i.“color”“black OR cat”Records containing either the word “black” or the word “cat” in the color field1, 3
j.“color”“b*”Records containing a word starting with “b” in the color field1, 3
k.“color”“black NOT cat”Records containing the word “black” but not the word “cat” in the color field1, 3