IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Match phrase query
editMatch phrase query
editThe match_phrase
query analyzes the text and creates a phrase
query
out of the analyzed text. For example:
resp = client.search( body={"query": {"match_phrase": {"message": "this is a test"}}}, ) print(resp)
response = client.search( body: { query: { match_phrase: { message: 'this is a test' } } } ) puts response
res, err := es.Search( es.Search.WithBody(strings.NewReader(`{ "query": { "match_phrase": { "message": "this is a test" } } }`)), es.Search.WithPretty(), ) fmt.Println(res, err)
GET /_search { "query": { "match_phrase": { "message": "this is a test" } } }
A phrase query matches terms up to a configurable slop
(which defaults to 0) in any order. Transposed terms have a slop of 2.
The analyzer
can be set to control which analyzer will perform the
analysis process on the text. It defaults to the field explicit mapping
definition, or the default search analyzer, for example:
resp = client.search( body={ "query": { "match_phrase": { "message": { "query": "this is a test", "analyzer": "my_analyzer", } } } }, ) print(resp)
response = client.search( body: { query: { match_phrase: { message: { query: 'this is a test', analyzer: 'my_analyzer' } } } } ) puts response
res, err := es.Search( es.Search.WithBody(strings.NewReader(`{ "query": { "match_phrase": { "message": { "query": "this is a test", "analyzer": "my_analyzer" } } } }`)), es.Search.WithPretty(), ) fmt.Println(res, err)
GET /_search { "query": { "match_phrase": { "message": { "query": "this is a test", "analyzer": "my_analyzer" } } } }
This query also accepts zero_terms_query
, as explained in match
query.