Skip to content

Conversation

ishag4
Copy link
Contributor

@ishag4 ishag4 commented Oct 1, 2025

Description

To fix bug where executing a case-insensitive wildcard query combined with aggregations causes an ArrayIndexOutOfBoundsException. The root cause is related to how Lucene’s automaton handles case-insensitive wildcards without determinizing the automaton, leading to instability during query execution.
This PR fixes the issue by explicitly determinizing the automaton generated for case-insensitive wildcard queries before passing it to Lucene’s query execution layer. By converting the automaton to a deterministic finite automaton (DFA), we prevent the exception and ensure stable query execution.

Related Issues

Resolves #19319

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@ishag4 ishag4 requested a review from a team as a code owner October 1, 2025 06:29
@github-actions github-actions bot added bug Something isn't working good first issue Good for newcomers Search:Aggregations labels Oct 1, 2025
Copy link
Contributor

github-actions bot commented Oct 1, 2025

❌ Gradle check result for 3efbfa1: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

@msfroh msfroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks @ishag4!

@msfroh
Copy link
Contributor

msfroh commented Oct 9, 2025

@ishag4 -- can you please add a CHANGELOG entry under the "Fixed" section?

Copy link
Contributor

github-actions bot commented Oct 9, 2025

❌ Gradle check result for 1919913: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

github-actions bot commented Oct 9, 2025

❌ Gradle check result for df497d1: null

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for df497d1: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for 5be518f: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

✅ Gradle check result for 5be518f: SUCCESS

Copy link

codecov bot commented Oct 11, 2025

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 73.02%. Comparing base (2695c93) to head (6094afd).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...nsearch/common/lucene/search/AutomatonQueries.java 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #19489      +/-   ##
============================================
- Coverage     73.06%   73.02%   -0.05%     
+ Complexity    70630    70568      -62     
============================================
  Files          5723     5723              
  Lines        323513   323522       +9     
  Branches      46852    46853       +1     
============================================
- Hits         236384   236259     -125     
- Misses        68013    68181     +168     
+ Partials      19116    19082      -34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

❌ Gradle check result for 5ecb63c: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for 43af818: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Automaton automaton = toCaseInsensitiveWildcardAutomaton(wildcardquery);
try {
automaton = Operations.determinize(automaton, Operations.DEFAULT_DETERMINIZE_WORK_LIMIT);
} catch (TooComplexToDeterminizeException e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question: Any other exceptions do we need to handle?

Also, let's add a test case for exception case?

Copy link
Contributor

❌ Gradle check result for f12a304: null

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

✅ Gradle check result for 6094afd: SUCCESS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working good first issue Good for newcomers Search:Aggregations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Error when use both wildcard + aggregation

3 participants