prefix-query.asciidoc 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 :
  27. [source,js]
  28. --------------------------------------------------
  29. GET /_search
  30. { "query": {
  31. "prefix" : { "user" : { "prefix" : "ki", "boost" : 2.0 } }
  32. }
  33. }
  34. --------------------------------------------------
  35. // CONSOLE
  36. This multi term query allows you to control how it gets rewritten using the
  37. <<query-dsl-multi-term-rewrite,rewrite>>
  38. parameter.