Query string query #
Returns documents that match a compact query-syntax string, e.g.
status:active AND title:search. The same parser powers the
URI search parameter ?q=.
Inside a
nestedquery: not supported yet — the clause is rejected with an HTTP 400 naming the offending clause.
Examples #
POST /my-collection/_search
{
"query": {
"query_string": {
"query": "status:active AND title:search"
}
}
}
Across several fields with per-field boosts:
POST /my-collection/_search
{
"query": {
"query_string": {
"query": "search engine",
"fields": ["title^3", "description"]
}
}
}
Parameters for query_string
#
query
(Required, string) The query-syntax string.default_field
(Optional, string, default:*) Field used for bare terms whenfieldsis empty.default_operator
(Optional, string, default:or) Default boolean operator between terms:ororand.fields
(Optional, array of strings) Multiple fields with optional boost (e.g.["title^3", "description"]). When non-empty, the query is expanded into abool.shouldacross these fields; each entry supports thefield^boostsyntax.type
(Optional, string) Multi-field scoring strategy:best_fields(max/dis_max) ormost_fields(sum — the default, for backward compatibility).tie_breaker
(Optional, float, default:0) Tie-breaker forbest_fieldsmode:max_score + tie_breaker * sum(other_scores). Range[0, 1].combination_strategy
(Optional, string) Multi-field score combination forfields:best_fields(max/dis_max) ormost_fields(sum). Defaults tomost_fields.