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

[BUG] Optional Characters in the end of strings lead to unexpected behavior #17232

Open
ysz0507 opened this issue Feb 3, 2025 · 0 comments
Open
Labels
bug Something isn't working Other untriaged

Comments

@ysz0507
Copy link

ysz0507 commented Feb 3, 2025

Describe the bug

I came across some weird behavior of the lucene regex matching.
My os database contains entries with the following values: abc, abc\, abc), abc&
In lucene regex have implicit anchors in the beginning and the and.

Regex Result Expected
ab does not match abc Expected
abc matches abc, abc\, abc), abc& Unexpected

So for abc is the anchor ignored for some characters?

Now let's say I want a query that only matches abc&:

Regex Result Expected
abc& Invalid query Expected since & is calculating a intersection
abc&& Nothing is matched ?
abc\& Nothing is matched Unexpected

I did not found a way to match explicitly abc&.

Note that this behavior exists with and without the optional parameter being enabled.

Related component

Other

To Reproduce

  1. Add entries with abc, abc\, abc) and abc& to the dataset.
  2. Execute:
GET <index>
{"query": 
{"bool": 
{"must": 
  [
    {"regexp": 
      {"crash_componedsfnt.keyword": 
        {"value": "<regex>", "flags": "ALL"}
      }
    }
  ], 
"must_not": [], 
"filter": {
  "range": {"crash_timestamp": {"gte": "now-6000m", "lte": "now"}}}}
}, 
"aggs": {"aggregation_result": {"cardinality": {"field": "config_name.keyword"}}}, 
"size": 10}
  1. See what entries are matched

Expected behavior

  1. The regex abc should only match abc and not abc\, abc), abc&
  2. The regex abc\& should match abc&

Additional Details

  • this behavior exists with and without the optional parameter being enabled.
  • OS: AL
  • Version 2.11.0

Version retrieved from curl -X GET "http://localhost:9200"

@ysz0507 ysz0507 added bug Something isn't working untriaged labels Feb 3, 2025
@github-actions github-actions bot added the Other label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Other untriaged
Projects
None yet
Development

No branches or pull requests

1 participant