prefix-query.asciidoc 978 B

123456789101112131415161718192021222324252627282930313233343536
  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. {
  10. "prefix" : { "user" : "ki" }
  11. }
  12. --------------------------------------------------
  13. A boost can also be associated with the query:
  14. [source,js]
  15. --------------------------------------------------
  16. {
  17. "prefix" : { "user" : { "value" : "ki", "boost" : 2.0 } }
  18. }
  19. --------------------------------------------------
  20. Or :
  21. [source,js]
  22. --------------------------------------------------
  23. {
  24. "prefix" : { "user" : { "prefix" : "ki", "boost" : 2.0 } }
  25. }
  26. --------------------------------------------------
  27. This multi term query allows you to control how it gets rewritten using the
  28. <<query-dsl-multi-term-rewrite,rewrite>>
  29. parameter.