match-phrase-query.asciidoc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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,js]
  9. --------------------------------------------------
  10. GET /_search
  11. {
  12. "query": {
  13. "match_phrase" : {
  14. "message" : "this is a test"
  15. }
  16. }
  17. }
  18. --------------------------------------------------
  19. // CONSOLE
  20. A phrase query matches terms up to a configurable `slop`
  21. (which defaults to 0) in any order. Transposed terms have a slop of 2.
  22. The `analyzer` can be set to control which analyzer will perform the
  23. analysis process on the text. It defaults to the field explicit mapping
  24. definition, or the default search analyzer, for example:
  25. [source,js]
  26. --------------------------------------------------
  27. GET /_search
  28. {
  29. "query": {
  30. "match_phrase" : {
  31. "message" : {
  32. "query" : "this is a test",
  33. "analyzer" : "my_analyzer"
  34. }
  35. }
  36. }
  37. }
  38. --------------------------------------------------
  39. // CONSOLE
  40. This query also accepts `zero_terms_query`, as explained in <<query-dsl-match-query, `match` query>>.