-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Fix an OOM error when creating to many chained synonym graph token filter. #140026
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
Merged
afoucret
merged 3 commits into
elastic:patch/serverless-fix
from
afoucret:fix-chained-synonyms-oom-reload
Dec 30, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
.../yamlRestTest/resources/rest-api-spec/test/analysis-common/50_chained_synonym_filters.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| --- | ||
| "Test chained synonym_graph filters": | ||
| - do: | ||
| indices.create: | ||
| index: test_chained_synonyms | ||
| body: | ||
| settings: | ||
| analysis: | ||
| filter: | ||
| synonyms_a: | ||
| type: synonym_graph | ||
| synonyms: [ "foo, bar" ] | ||
| synonyms_b: | ||
| type: synonym_graph | ||
| synonyms: [ "baz, qux" ] | ||
| synonyms_c: | ||
| type: synonym_graph | ||
| synonyms: [ "hello, world" ] | ||
| analyzer: | ||
| chained_syn: | ||
| tokenizer: standard | ||
| filter: [ lowercase, synonyms_a, synonyms_b, synonyms_c ] | ||
| mappings: | ||
| properties: | ||
| text: | ||
| type: text | ||
| analyzer: chained_syn | ||
|
|
||
| - do: | ||
| index: | ||
| index: test_chained_synonyms | ||
| id: "1" | ||
| body: | ||
| text: "foo baz hello" | ||
| refresh: true | ||
|
|
||
| # Test that all three chained synonym filters work correctly | ||
| - do: | ||
| search: | ||
| index: test_chained_synonyms | ||
| body: | ||
| query: | ||
| match: | ||
| text: "bar qux world" | ||
| - match: { hits.total.value: 1 } | ||
| - match: { hits.hits.0._id: "1" } | ||
|
|
||
| # Verify analyzer behavior - synonym_graph produces synonym first, then original | ||
| - do: | ||
| indices.analyze: | ||
| index: test_chained_synonyms | ||
| body: | ||
| text: "foo" | ||
| analyzer: chained_syn | ||
| - length: { tokens: 2 } | ||
| - match: { tokens.0.position: 0 } | ||
| - match: { tokens.1.position: 0 } | ||
|
|
||
| # Test with multi-word query to verify all chained filters work together | ||
| - do: | ||
| indices.analyze: | ||
| index: test_chained_synonyms | ||
| body: | ||
| text: "foo baz hello" | ||
| analyzer: chained_syn | ||
| # Each word that matches a synonym expands to 2 tokens: foo→(foo,bar), baz→(baz,qux), hello→(hello,world) | ||
| - length: { tokens: 6 } | ||
| # Verify positions: each synonym pair at same position | ||
| - match: { tokens.0.position: 0 } | ||
| - match: { tokens.1.position: 0 } | ||
| - match: { tokens.2.position: 1 } | ||
| - match: { tokens.3.position: 1 } | ||
| - match: { tokens.4.position: 2 } | ||
| - match: { tokens.5.position: 2 } | ||
| # Verify token content - synonym_graph produces synonym first, then original | ||
| - match: { tokens.0.token: "bar" } | ||
| - match: { tokens.1.token: "foo" } | ||
| - match: { tokens.2.token: "qux" } | ||
| - match: { tokens.3.token: "baz" } | ||
| - match: { tokens.4.token: "world" } | ||
| - match: { tokens.5.token: "hello" } | ||
|
|
||
| # Test that analyzer reload doesn't cause issues (critical for the fix) | ||
| - do: | ||
| indices.close: | ||
| index: test_chained_synonyms | ||
|
|
||
| - do: | ||
| indices.open: | ||
| index: test_chained_synonyms | ||
|
|
||
| # Verify it still works after reload | ||
| - do: | ||
| search: | ||
| index: test_chained_synonyms | ||
| body: | ||
| query: | ||
| match: | ||
| text: "bar qux world" | ||
| - match: { hits.total.value: 1 } | ||
| - match: { hits.hits.0._id: "1" } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to help the test GC along, you may want to place:
at the end of the test. (context: playing with the test, I had it loop through the entire test 20 times, and it OOM'd for me... adding this inside the loop, it passed). Not saying an OOM will happen during a CI test run with just the one time through in the test, but it can't hurt just in case.