ElasticSearch provides a helper to build complex span queries, which depends on simple preconfigured settings. This helper is called the match query.
For executing a match query, we need to perform the following steps:
The standard usage of a
match
query simply requires the field name and the query text. For example:curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search' -d '{ "query": { "match" : { "parsedtext" : "nice guy", "operator": "and" } } }'
If you need to execute the same query as a phrase query, the type from
match
changes tomatch_phrase
, as given in the following code:curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search' -d '{ "query": { "match_phrase" : { "parsedtext" : "nice guy" } } }'
An extension of the previous query used in text completion or the "search as you type" functionality...