multi-match-query.asciidoc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. [[query-dsl-multi-match-query]]
  2. === Multi Match Query
  3. The `multi_match` query builds further on top of the `match` query by
  4. allowing multiple fields to be specified. The idea here is to allow to
  5. more easily build a concise match type query over multiple fields
  6. instead of using a relatively more expressive query by using multiple
  7. match queries within a `bool` query.
  8. The structure of the query is a bit different. Instead of a nested json
  9. object defining the query field, there is a top json level field for
  10. defining the query fields. Example:
  11. [source,js]
  12. --------------------------------------------------
  13. {
  14. "multi_match" : {
  15. "query" : "this is a test",
  16. "fields" : [ "subject", "message" ]
  17. }
  18. }
  19. --------------------------------------------------
  20. The `multi_match` query creates either a `bool` or a `dis_max` top level
  21. query. Each field is a query clause in this top level query. The query
  22. clause contains the actual query (the specified 'type' defines what
  23. query this will be). Each query clause is basically a `should` clause.
  24. [float]
  25. [float]
  26. ==== Options
  27. All options that apply on the `match` query also apply on the
  28. `multi_match` query. The `match` query options apply only on the
  29. individual clauses inside the top level query.
  30. * `fields` - Fields to be used in the query.
  31. * `use_dis_max` - Boolean indicating to either create a `dis_max` query
  32. or a `bool` query. Defaults to `true`.
  33. * `tie_breaker` - Multiplier value to balance the scores between lower
  34. and higher scoring fields. Only applicable when `use_dis_max` is set to
  35. true. Defaults to `0.0`.
  36. The query accepts all the options that a regular `match` query accepts.
  37. [float]
  38. [float]
  39. ==== Boosting
  40. The `multi_match` query supports field boosting via `^` notation in the
  41. fields json field.
  42. [source,js]
  43. --------------------------------------------------
  44. {
  45. "multi_match" : {
  46. "query" : "this is a test",
  47. "fields" : [ "subject^2", "message" ]
  48. }
  49. }
  50. --------------------------------------------------
  51. In the above example hits in the `subject` field are 2 times more
  52. important than in the `message` field.