array-compare.asciidoc 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. [role="xpack"]
  2. [[condition-array-compare]]
  3. === Array compare condition
  4. Use `array_compare` to compare an array of values in the execution context to a
  5. given value. See <<condition-compare-operators>>
  6. for the operators you can use.
  7. ==== Using an array compare condition
  8. To use the `array_compare` condition, you specify the array in the execution
  9. context that you want to evaluate, a
  10. <<condition-compare-operators,comparison operator>>, and the value you want to
  11. compare against. Optionally, you can specify the path to the field in each array
  12. element that you want to evaluate.
  13. For example, the following `array_compare` condition returns `true` if there
  14. is at least one bucket in the aggregation that has a `doc_count` greater
  15. than or equal to 25:
  16. [source,js]
  17. --------------------------------------------------
  18. {
  19. "condition": {
  20. "array_compare": {
  21. "ctx.payload.aggregations.top_tweeters.buckets" : { <1>
  22. "path": "doc_count", <2>
  23. "gte": { <3>
  24. "value": 25 <4>
  25. }
  26. }
  27. }
  28. }
  29. }
  30. --------------------------------------------------
  31. // NOTCONSOLE
  32. <1> The path to the array in the execution
  33. context that you want to evaluate, specified in dot notation.
  34. <2> The path to the field in each array element that you want to evaluate.
  35. <3> The <<condition-compare-operators,comparison operator>> to use.
  36. <4> The comparison value. Supports date math like the
  37. <<compare-condition-date-math,compare condition>>.
  38. NOTE: When using fieldnames that contain a dot this condition will not
  39. work, use a <<condition-script,script condition>> instead.
  40. ==== Array-compare condition attributes
  41. [options="header"]
  42. |======
  43. | Name | Description
  44. |`<array path>` | The path to the array in the execution
  45. context, specified in dot notation.
  46. For example, `ctx.payload.aggregations.top_tweeters.buckets`.
  47. | `<array path>.path` | The path to the field in each array element
  48. that you want to evaluate. For example,
  49. `doc_count`. Defaults to an empty string.
  50. | `<array path>.<operator>.quantifier` | How many matches are required for the
  51. comparison to evaluate to `true`: `some`
  52. or `all`. Defaults to `some`--there must
  53. be at least one match. If the array is
  54. empty, the comparison evaluates to `true`
  55. if the quantifier is set to `all` and
  56. `false` if the quantifier is set to
  57. `some`.
  58. | `<array path>.<operator>.value` | The value to compare against.
  59. |======