span-multi-term-query.asciidoc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. [[query-dsl-span-multi-term-query]]
  2. === Span multi-term query
  3. ++++
  4. <titleabbrev>Span multi-term</titleabbrev>
  5. ++++
  6. The `span_multi` query allows you to wrap a `multi term query` (one of wildcard,
  7. fuzzy, prefix, range or regexp query) as a `span query`, so
  8. it can be nested. Example:
  9. [source,js]
  10. --------------------------------------------------
  11. GET /_search
  12. {
  13. "query": {
  14. "span_multi":{
  15. "match":{
  16. "prefix" : { "user" : { "value" : "ki" } }
  17. }
  18. }
  19. }
  20. }
  21. --------------------------------------------------
  22. // CONSOLE
  23. A boost can also be associated with the query:
  24. [source,js]
  25. --------------------------------------------------
  26. GET /_search
  27. {
  28. "query": {
  29. "span_multi":{
  30. "match":{
  31. "prefix" : { "user" : { "value" : "ki", "boost" : 1.08 } }
  32. }
  33. }
  34. }
  35. }
  36. --------------------------------------------------
  37. // CONSOLE
  38. WARNING: `span_multi` queries will hit too many clauses failure if the number of terms that match the query exceeds the
  39. boolean query limit (defaults to 1024).To avoid an unbounded expansion you can set the <<query-dsl-multi-term-rewrite,
  40. rewrite method>> of the multi term query to `top_terms_*` rewrite. Or, if you use `span_multi` on `prefix` query only,
  41. you can activate the <<index-prefixes,`index_prefixes`>> field option of the `text` field instead. This will
  42. rewrite any prefix query on the field to a single term query that matches the indexed prefix.