Match phrase query

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 nested query: supported — the phrase, including its slop, 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.

Calendar September 27, 2026
Edit Edit this page