Skip to content

Default Operator

Edit page

The default operator for text queries can be set by using the desired modifier.

OR uses the _or modifier (the default).

AND uses the _and modifier.

To make AND the default operator and thus forcing a query to search for all terms instead of any term (which is the default):

SEARCH /bank/
{
"_query": {
"personality": {
"_and": "these days are few and far between"
}
}
}

The default operator of the words of a text can also be:

  • _near, _phrase: the words as a near or phrase group.
  • _synonym: the words are synonyms, and weigh once.
  • _max: the weight is the maximum of the words’ weights, not the sum.

Choosing _and or _or also lets the text use the boolean words (AND, OR, NOT, XOR, NEAR, ADJ) described in the query string grammar; a plain string reads them as words. Sources: src/query_dsl.cc:805-823.