elastic/logstash

Extend 'in' operator to check for array subset.

Open

Aperta il 29 mar 2017

Vedi su GitHub
 (8 commenti) (0 reazioni) (0 assegnatari)Ruby (14.197 star) (3496 fork)batch import
discussenhancementhelp wanted

Descrizione

Currently, the in operator does the following for a in b example:

  • if b is a string, it checks if a is a substring of b
  • if b is a list, it checks if a is an element of b

I propose that we extend the in operator to have the following additional behavior:

  • if b is a list, and a is a list, then a in b should check if a is a subset of the elements in b

Examples:

  • ["a", "b"] in ["a", "b", "c"] == true
  • ["a", "d"] in ["a", "b", "c"] == false

The same goes for field references. Let's suppose the [tags] field is ["web", "frontend", "newyork", "staging"], then the following:

  • ["web", "frontend"] in [tags] == true
  • ["db", "newyork"] in [tags] == false

General idea is to have in act as a subset check if both operands are list values (array literals, fieldreferences that have array values, etc)

Guida contributor