minimum-should-match.asciidoc 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. [[query-dsl-minimum-should-match]]
  2. == Minimum Should Match
  3. The `minimum_should_match` parameter possible values:
  4. [cols="<,<,<",options="header",]
  5. |=======================================================================
  6. |Type |Example |Description
  7. |Integer |`3` |Indicates a fixed value regardless of the number of
  8. optional clauses.
  9. |Negative integer |`-2` |Indicates that the total number of optional
  10. clauses, minus this number should be mandatory.
  11. |Percentage |`75%` |Indicates that this percent of the total number of
  12. optional clauses are necessary. The number computed from the percentage
  13. is rounded down and used as the minimum.
  14. |Negative percentage |`-25%` |Indicates that this percent of the total
  15. number of optional clauses can be missing. The number computed from the
  16. percentage is rounded down, before being subtracted from the total to
  17. determine the minimum.
  18. |Combination |`3<90%` |A positive integer, followed by the less-than
  19. symbol, followed by any of the previously mentioned specifiers is a
  20. conditional specification. It indicates that if the number of optional
  21. clauses is equal to (or less than) the integer, they are all required,
  22. but if it's greater than the integer, the specification applies. In this
  23. example: if there are 1 to 3 clauses they are all required, but for 4 or
  24. more clauses only 90% are required.
  25. |Multiple combinations |`2<-25% 9<-3` |Multiple conditional
  26. specifications can be separated by spaces, each one only being valid for
  27. numbers greater than the one before it. In this example: if there are 1
  28. or 2 clauses both are required, if there are 3-9 clauses all but 25% are
  29. required, and if there are more than 9 clauses, all but three are
  30. required.
  31. |=======================================================================
  32. *NOTE:*
  33. When dealing with percentages, negative values can be used to get
  34. different behavior in edge cases. 75% and -25% mean the same thing when
  35. dealing with 4 clauses, but when dealing with 5 clauses 75% means 3 are
  36. required, but -25% means 4 are required.
  37. If the calculations based on the specification determine that no
  38. optional clauses are needed, the usual rules about BooleanQueries still
  39. apply at search time (a BooleanQuery containing no required clauses must
  40. still match at least one optional clause)
  41. No matter what number the calculation arrives at, a value greater than
  42. the number of optional clauses, or a value less than 1 will never be
  43. used. (ie: no matter how low or how high the result of the calculation
  44. result is, the minimum number of required matches will never be lower
  45. than 1 or greater than the number of clauses.