query clause
The query clause is the most fundamental part of a statement. It defines what to search for and which index field to search against. Combine multiple conditions using logical operators — AND, OR, ANDNOT, and RANK — to express precise search intent.
For example, suppose a table has a title field and a subject field, both of TEXT type. Create a composite index named default on these fields, then use the default index in the query clause to find documents where either field contains the search query.
To search only the title field, create an index named title_search based on that field. A query using title_search returns only documents where title values match.
Syntax
Simple queries
Syntax:
query=Index name:'Search query'^boost Logical operator Index name:'Search query'^boost
Index name: the index to search against. The index must exist in the index schema. The query finds documents where the source fields of the index contain the search query.
Search query: the content to search for.
boost: a relevance weight for the search query. Must be an INT. Valid values: [0, 99]. Default: 99.
-
Logical operator: connects multiple query conditions. Operators must be uppercase. Supported operators —
(),AND,OR,ANDNOT, andRANK— and their precedence (lowest to highest): RANK < OR < AND < ANDNOT < (). Use parentheses to override default precedence when combining multiple operators.Operator
Description
ANDReturns documents matching both conditions.
ORReturns documents matching either condition.
ANDNOTReturns documents matching the left condition but not the right.
RANKReturns documents matching the left condition; uses the right condition only to adjust relevance scores, not to filter results.
()Groups conditions to control evaluation order. Highest precedence.
AND: Returns only documents that match both conditions. Example:
query=default:'Mobile Phone' AND default:'Bluetooth'returns documents containing both Mobile Phone and Bluetooth.OR: Returns documents that match either condition. Example:
query=default:'Mobile Phone' OR default:'Bluetooth'returns documents containing Mobile Phone or Bluetooth.ANDNOT: Returns documents matching the left condition only. Example:
query=default:'Mobile Phone' ANDNOT default:'Bluetooth'returns documents containing Mobile Phone but not Bluetooth.RANK: Returns documents matching the left condition, with the right condition influencing relevance scoring only — it does not filter results. Example:
query=default:'Mobile Phone' RANK default:'Bluetooth'returns all documents containing Mobile Phone, ranked higher when they also contain Bluetooth.
Advanced queries
Multiple search queries on the same index
Syntax:
query=Index name:'Search query'^boost | 'Search query'^boost
query=Index name:'Search query'^boost & 'Search query'^boost
The vertical bar (|) is the OR operator. The ampersand (&) is the AND operator.
Phrase queries
Syntax:
query=Index name:"Search query"^boost Logical operator Index name:"Search query"^boost
Enclose the search query in double quotation marks (") to run a phrase query. In a phrase query, all terms must appear consecutively in the same order, both before and after analysis.
A search query enclosed in double quotation marks (
") is treated as a phrase query: all terms must be adjacent and in the same order before and after analysis.Range queries include geography queries and value range queries.
Geography queries
Syntax:
query=Index name:'SHAPE(ARGS...)'
Supported shape types for SHAPE(ARGS...):
Point:
point(LON LAT)— LON is the longitude and LAT is the latitude, separated by a space.Circle:
circle(LON LAT,Radius)— LON and LAT define the center; Radius is the radius in meters.Rectangle:
rectangle(minLON minLAT,maxLON maxLAT)— maxLAT must be greater than or equal to minLAT (swapped automatically if not); minLON must be less than maxLON (incorrect results if not).Polygon:
polygon(LON1 LAT1,LON2 LAT2,LON3 LAT3,LON4 LAT4,...)— supports convex and concave polygons. The start and end points must be the same. Adjacent sides must not be collinear, and sides must not intersect.
Note:
The index must be of the SPATIAL type.
Enclose the shape expression in single quotation marks. Example:
query=spatial_index:'circle(130.0 10.0,1000.0)'.Point coordinates for lines and polygons are mapped to a flat world map regardless of whether they cross the 180-degree longitude line. The inverted index query result for location fields is accurate. Results for line and polygon fields require post-query filtering.
Value range queries
Syntax:
query=Index name:(Numeric 1,Numeric 2]
Numeric 1 is the range start; Numeric 2 is the range end. Use parentheses for open endpoints (exclusive) and brackets for closed endpoints (inclusive).
Examples:
query=price:(3,100) — greater than 3 and less than 100.
query=price:[3,100] — greater than or equal to 3 and less than or equal to 100.
query=price:(3,100] — greater than 3 and less than or equal to 100.
query=price:(, 100) — less than 100 (no lower bound specified).
Note:
The index field must be of a numeric type.
Values must be integers. Floating-point numbers are not supported.
Date queries
Syntax:
query=Index name:(Start time,End time).
Start time and end time are INTEGER timestamps in milliseconds. If start time is omitted, the scan begins from 0. If end time is omitted, the default is 4102416000000 (2100-01-01 00:00). Open and closed endpoints are supported.
Note:
The index field must be of the DATE type.
Timestamps must be INTEGER type, accurate to milliseconds. Timestamps exceeding 4102416000000 are capped at 4102416000000.