1
0

prefix-query.asciidoc 867 B

123456789101112131415161718192021222324252627282930313233
  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. This multi term query allows you to control how it gets rewritten using the
  27. <<query-dsl-multi-term-rewrite,rewrite>>
  28. parameter.