-
Notifications
You must be signed in to change notification settings - Fork 0
Query String Query
A query that uses a query parser in order to parse its content. Here is an example:
GET /_search
{
"query": {
"query_string" : {
"default_field" : "content",
"query" : "this AND that OR thus"
}
}
}The query_string query parses the input and splits text around operators. Each textual part is analyzed independently of each other. For instance the following query:
GET /_search
{
"query": {
"query_string" : {
"default_field" : "content",
"query" : "(new york city) OR (big apple)"
}
}
}Will be split into new york city and big apple and each part is then analyzed independently by the analyzer configured for the field.
Note: Whitespaces are not considered operators, this means that new york city will be passed "as is" to the analyzer configured for the field. If the field is a keyword field the analyzer will create a single term new york city and the query builder will use this term in the query. If you want to query each term separately you need to add explicit operators around the terms (e.g. new AND york AND city).
When multiple fields are provided it is also possible to modify how the different field queries are combined inside each textual part using the type parameter. The possible modes are described here and the default is best_fields.
The query_string top level parameters include:
-
query: The actual query to be parsed. See Query string syntax. -
default_field: The default field for query terms if no prefix field is specified. Defaults to theindex.query.default_fieldindex settings, which in turn defaults to*. *extracts all fields in the mapping that are eligible to term queries and filters the metadata fields. All extracted fields are then combined to build a query when no prefix field is provided. -
default_operator: The default operator used if no explicit operator is specified. For example, with a default operator ofOR, the querycapital of Hungaryis translated tocapital OR of OR Hungary, and with default operator ofAND, the same query is translated tocapital AND of AND Hungary. The default value is OR. -
analyzer: The analyzer name used to analyze the query string.