A query clause defines what to search for and which index to search against — it is required in every OpenSearch statement.
Combine multiple query clauses with logical operators to build compound searches. The full syntax is:
query=<index>:'<search query>'^<boost> <OPERATOR> <index>:'<search query>'^<boost>Parameters
| Parameter | Description | Default |
|---|---|---|
<index> | The index to search. Must exist in your index schema. | — |
<search query> | The terms to search for. | — |
^<boost> | Relevance weight. Type: INT. Range: 0–99. | 99 |
Logical operators
All operators must be uppercase. When multiple operators appear in one clause, they are evaluated in this priority order (lowest to highest):
RANK < OR < AND < ANDNOT < ()
| Operator | Returns | Example |
|---|---|---|
AND | Documents matching both conditions | query=default:'Mobile Phone' AND default:'Bluetooth' |
OR | Documents matching either condition | query=default:'Mobile Phone' OR default:'Bluetooth' |
ANDNOT | Documents matching the left condition only | query=default:'Mobile Phone' ANDNOT default:'Bluetooth' |
RANK | Documents matching the left condition; right condition affects relevance scores only | query=default:'Mobile Phone' RANK default:'Bluetooth' |
How RANK works: Use RANK when a condition should influence ranking but not filter results. In query=default:'Mobile Phone' RANK default:'Bluetooth', all documents containing "Mobile Phone" are returned, but those also containing "Bluetooth" receive higher relevance scores.
Query types
Simple queries
Search a single index for one or more terms:
query=<index>:'<search query>'^<boost>Example: Search a composite index named default for documents containing "Mobile Phone":
query=default:'Mobile Phone'To run multiple search queries against the same index without repeating the index name, use | (OR) or & (AND):
query=<index>:'<search query>'^<boost> | '<search query>'^<boost>
query=<index>:'<search query>'^<boost> & '<search query>'^<boost>Phrase queries
Enclose the search query in double quotation marks to match an exact phrase. Terms must appear in the same order and adjacent to each other, both before and after analysis:
query=<index>:"<search query>"^<boost>Example: Match the exact phrase "running shoes":
query=default:"running shoes"Weakand queries
A weakand query is designed for long search queries. Instead of requiring all analyzed terms to appear in a document (AND) or accepting any single term (OR), it retrieves documents that contain at least a specified minimum number of terms. This improves performance, and a higher minimum term count yields better results.
Specify the minimum using one of two syntaxes:
| Syntax | When to use | How the minimum is determined |
|---|---|---|
query=<index>:('<term1>'||'<term2>')^<number> | You have already analyzed the query manually | ^<number> is the exact minimum term count |
query=<index>:('<search query>')^^<number> | The engine analyzes the query | ^^<number> is a ratio (3 decimal places); minimum = round(total terms × ratio) |
The second syntax handles cases where the total number of analyzed terms is large and unpredictable.
Weakand queries are disabled by default. Contact technical support to enable this feature.
Geography queries
Search a SPATIAL index using geographic shapes:
query=<spatial-index>:'<SHAPE(ARGS...)>'Enclose the shape expression in single quotation marks. Supported shapes:
| Shape | Syntax | Notes |
|---|---|---|
| Point | point(LON LAT) | Separate longitude and latitude with a space |
| Circle | circle(LON LAT,Radius) | Radius unit: meters |
| Rectangle | rectangle(minLON minLAT,maxLON maxLAT) | maxLAT must be ≥ minLAT (auto-corrected if violated); minLON must be < maxLON (not auto-corrected — incorrect results if violated) |
| Polygon | polygon(LON1 LAT1,LON2 LAT2,...) | Convex or concave; start point and end point must be the same; adjacent sides must not be collinear; sides must not intersect |
Example: Query a circle with center at longitude 130.0, latitude 10.0, and radius 1,000 meters:
query=spatial_index:'circle(130.0 10.0,1000.0)'Accuracy notes:
Point coordinates in line and polygon queries are mapped to a flat world map, regardless of whether the 180° longitude line is crossed.
Inverted index results for location fields are accurate. Results for line and polygon fields require additional filtering.
Value range queries
Search a numeric index for values within a specified range. Use ( or ) for open endpoints (exclusive) and [ or ] for closed endpoints (inclusive):
query=<index>:(<Numeric 1>,<Numeric 2>]Examples:
| Query | Matches |
|---|---|
query=price:(3,100) | 3 < price < 100 |
query=price:[3,100] | 3 ≤ price ≤ 100 |
query=price:(3,100] | 3 < price ≤ 100 |
query=price:(,100) | price < 100 (no lower bound) |
Constraints: The index field must be a numeric type. Only integer values are supported — floating-point numbers are not.
Date queries
Search a DATE index for timestamps within a specified range:
query=<index>:(<Start time>,<End time>]Timestamps must be INTEGER values in milliseconds. Open and closed endpoint notation follows the same rules as value range queries.
| Boundary | Default value | Equivalent date |
|---|---|---|
| Start time (omitted) | 0 | — |
| End time (omitted) | 4102416000000 | 2100-01-01 00:00 |
If the specified end timestamp exceeds 4102416000000, the system uses 4102416000000.
Constraint: The index field must be of DATE type.