Match phrase query #
Returns documents that contain the exact sequence of terms, in order,
with no other terms in between (modulo slop). The text is analyzed
before matching, like the
match query.
Inside a
nestedquery: supported — the phrase, including itsslop, must be satisfied by ONE array element; terms keep query order.
Examples #
POST /my-collection/_search
{
"query": {
"match_phrase": {
"field": "message",
"query": "this is a test"
}
}
}
Allow words in between with slop:
POST /my-collection/_search
{
"query": {
"match_phrase": {
"field": "message",
"query": "this test",
"slop": 3
}
}
}
Parameters for match_phrase
#
<field>
(Required, string) Field you wish to search.query
(Required, string) The phrase you wish to find in the provided<field>; analyzed before matching.analyzer
(Optional, string) Analyzer used to convert the text into terms. Defaults to the field’s search analyzer.slop
(Optional, float, default:0) Maximum number of positions the terms may be shifted to match the phrase.
phrase is accepted as the native alias of the same query.