Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EQL: Introduce explicit equality operator for strings #62941

Closed
costin opened this issue Sep 28, 2020 · 3 comments
Closed

EQL: Introduce explicit equality operator for strings #62941

costin opened this issue Sep 28, 2020 · 3 comments
Labels
:Analytics/EQL EQL querying >breaking >feature Team:QL (Deprecated) Meta label for query languages team

Comments

@costin
Copy link
Member

costin commented Sep 28, 2020

Currently == has overloaded semantics namely:

  • supporting case-insensitive comparison
  • supporting "*" wildcard pattern.

which have proven problematic.
Instead of overloading ==, a new comparison operator is introduced that takes over these semantics, leaving == with exact ones.

The current proposals for the newly introduced operator are:
a. : / !:
b. =~ / !~

Regardless of the actual operator being used, the new operator will:

  • always perform case-insensitive comparisons
  • will support the "*" wildcard pattern, that is comparing it to a string literal that contains *, will be equivalent to a wildcard match. To escape * in a string, use \:
where a <op> `*`    // wildcard(a,"*")
where a <op> `foo*` // wildcard(a, "foo*")
where a <op> concat("foo", "*") // a == contact("foo", "*")
where a <op> `\*`   // a == "*"
  • the operator does not combine with any other operator (>, >=, ==, etc..).
  • there is no parameter, option or support for supporting the existing EQL behavior, that is == is always exact and there is no way to make == behave like the newly introduced operator.

Relates to (see #62651 (comment)).

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-ql (:Query Languages/EQL)

@elasticmachine elasticmachine added the Team:QL (Deprecated) Meta label for query languages team label Sep 28, 2020
@costin
Copy link
Member Author

costin commented Sep 28, 2020

Relates #62883

@costin costin removed the >bug label Sep 28, 2020
costin added a commit to costin/elasticsearch that referenced this issue Oct 1, 2020
Introduce : and !: operator for doing case insensitive string
comparisons. When dealing with non-string, the operator gets optimized
to usual equality checks so that it can be combined with other
operators.

Relates elastic#62941
costin added a commit that referenced this issue Oct 1, 2020
Introduce : operator for doing case insensitive string comparisons. 
Recognizes "*" for wildcard matches in string literals.
Restricted only to string types.

Relates #62941
costin added a commit that referenced this issue Oct 1, 2020
Introduce : operator for doing case insensitive string comparisons.
Recognizes "*" for wildcard matches in string literals.
Restricted only to string types.

Relates #62941

(cherry picked from commit 201e577)
@costin
Copy link
Member Author

costin commented Oct 2, 2020

Addressed through 201e577
Went ahead with : for operator. The negating operator !: hasn't not been added since most queries are about inclusion not exclusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/EQL EQL querying >breaking >feature Team:QL (Deprecated) Meta label for query languages team
Projects
None yet
Development

No branches or pull requests

2 participants