All Products
Search
Document Center

OpenSearch:query clause

Last Updated:Apr 01, 2026

The query clause is a required part of every search request. It specifies what to search for and which index field to search in. Combine multiple conditions using logical operators to build complex queries.

For example, you can combine the title and subject fields of the TEXT type to create the composite index field default. Then, you can perform searches based on the index field default to retrieve the documents where the title or subject field contains the search query.

You can also use only the title field to create the index field title_search. Then, when you perform searches based on the index field title_search, only the documents where the title field contains the search query can be retrieved.

Syntax

A query clause takes one of the following forms:

Query typeSyntax
Keyword searchindex:'<search query>' ^ boost
Geographic range searchindex:'circle (<longitude>, <latitude>, <radius>)'
Numeric range searchindex:[<value1>, <value2>]

Parameters

ParameterTypeRequiredDescription
indexStringYesThe index field to search. Configured when you define the index schema.
search queryStringYesThe term or phrase to search for. Enclose in single quotation marks (') or double quotation marks ("").
boostINTNoRelevance weight for the query condition. Valid values: 0–99. Default: 99. Values below 0 are treated as 0; values above 99 are treated as 99. Takes effect only when exact_match_boost() is configured in a rough sort expression.

Logical operators

Combine multiple query conditions using the following operators. All operators must be uppercase.

OperatorLogicPriority (lowest to highest)Example
RANKDocuments matching the second condition are ranked higher1 (lowest)title:'cloud' RANK title:'search'
OREither condition must match2title:'cloud' OR title:'search'
ANDBoth conditions must match3title:'cloud' AND type:'1'
ANDNOTFirst condition matches; documents matching the second are excluded4title:'cloud' ANDNOT title:'storage'
()Grouping — evaluated first5 (highest)(title:'a' OR title:'b') AND type:'1'

The | character is an alternate form of OR:

query=title:'Peking University'|'Zhejiang University'

Phrase queries

Enclose a search query in double quotation marks to perform a phrase query. In a phrase query, all the terms are connected and arranged in the same order before and after analysis.

query=title:"Peking University"

This returns only documents where the title contains "Peking University" as a phrase. Documents containing "University in Beijing" are not returned.

Examples

Search by a single field

query=title:'Peking University'

AND: both conditions must match

query=title:'Peking University' AND title:'Zhejiang University'

OR with AND: mixed conditions

query=(title:'Peking University' OR title:'Zhejiang University') AND type:'1'

ANDNOT with RANK: exclude and boost

query=(title:'Peking University' ANDNOT title:'Tsinghua') RANK title:'Principal'
// Fine sort expression: text_relevance(title)

Documents whose title contains "Peking University" but not "Tsinghua" are returned. Among them, documents whose title also contains "Principal" are ranked higher.

Search an ARRAY type index field

// arr_index_1 is an index built on an INT ARR field.
// Returns documents where arr_index_1 contains the value 1.
query=arr_index_1:'1'

Usage notes

  • The query clause is required and cannot be empty.

  • Search queries must be enclosed in single quotation marks (') or double quotation marks (""). A missing quotation mark causes a query error or unexpected results.

  • Only TEXT and SHORT_TEXT fields can be combined to create a composite index.

  • For how terms are analyzed and tokenized, see Built-in analyzer.

  • For geographic and numeric range queries, see Range search.