prefix-query.asciidoc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. [[query-dsl-prefix-query]]
  2. === Prefix Query
  3. Matches documents that have fields containing terms with a specified
  4. prefix (*not analyzed*). The prefix query maps to Lucene `PrefixQuery`.
  5. The following matches documents where the user field contains a term
  6. that starts with `ki`:
  7. [source,js]
  8. --------------------------------------------------
  9. GET /_search
  10. { "query": {
  11. "prefix" : { "user" : "ki" }
  12. }
  13. }
  14. --------------------------------------------------
  15. // CONSOLE
  16. A boost can also be associated with the query:
  17. [source,js]
  18. --------------------------------------------------
  19. GET /_search
  20. { "query": {
  21. "prefix" : { "user" : { "value" : "ki", "boost" : 2.0 } }
  22. }
  23. }
  24. --------------------------------------------------
  25. // CONSOLE
  26. Or with the `prefix` deprecated[5.0.0, Use `value`] syntax:
  27. [source,js]
  28. --------------------------------------------------
  29. GET /_search
  30. { "query": {
  31. "prefix" : { "user" : { "prefix" : "ki", "boost" : 2.0 } }
  32. }
  33. }
  34. --------------------------------------------------
  35. // CONSOLE
  36. // TEST[warning:Deprecated field [prefix] used, expected [value] instead]
  37. This multi term query allows you to control how it gets rewritten using the
  38. <<query-dsl-multi-term-rewrite,rewrite>>
  39. parameter.