prefix-query.asciidoc 911 B

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