match-phrase-query.asciidoc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. [[query-dsl-match-query-phrase]]
  2. === Match phrase query
  3. ++++
  4. <titleabbrev>Match phrase</titleabbrev>
  5. ++++
  6. The `match_phrase` query analyzes the text and creates a `phrase` query
  7. out of the analyzed text. For example:
  8. [source,console]
  9. --------------------------------------------------
  10. GET /_search
  11. {
  12. "query": {
  13. "match_phrase": {
  14. "message": "this is a test"
  15. }
  16. }
  17. }
  18. --------------------------------------------------
  19. A phrase query matches terms up to a configurable `slop`
  20. (which defaults to 0) in any order. Transposed terms have a slop of 2.
  21. The `analyzer` can be set to control which analyzer will perform the
  22. analysis process on the text. It defaults to the field explicit mapping
  23. definition, or the default search analyzer, for example:
  24. [source,console]
  25. --------------------------------------------------
  26. GET /_search
  27. {
  28. "query": {
  29. "match_phrase": {
  30. "message": {
  31. "query": "this is a test",
  32. "analyzer": "my_analyzer"
  33. }
  34. }
  35. }
  36. }
  37. --------------------------------------------------
  38. This query also accepts `zero_terms_query`, as explained in <<query-dsl-match-query, `match` query>>.