forked from qodo-benchmark/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
[main] Fix an OOM error when creating to many chained synonym graph token filter. (#140026) #8
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
Open
tomerqodo
wants to merge
4
commits into
codex_only-issues-20260113-augment-codex-sentry_base_main_fix_an_oom_error_when_creating_to_many_chained_synonym_graph_token_filter_140026_pr68
Choose a base branch
from
codex_only-issues-20260113-augment-codex-sentry_head_main_fix_an_oom_error_when_creating_to_many_chained_synonym_graph_token_filter_140026_pr68
base: codex_only-issues-20260113-augment-codex-sentry_base_main_fix_an_oom_error_when_creating_to_many_chained_synonym_graph_token_filter_140026_pr68
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
930ce6e
Fix an OOM error when creating to many chained synonym graph token fi…
afoucret 3538330
Merge branch 'main' into backport/main/pr-140026
afoucret e907faa
Merge branch 'main' into backport/main/pr-140026
afoucret 8aaa34f
Apply changes for benchmark PR
tomerqodo 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: "foo" } | ||
| - match: { tokens.1.token: "bar" } | ||
| - 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.
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.
In chained synonym_graph setups,
buildSynonymAnalyzer(...)(inSynonymTokenFilterFactory) builds the synonym parser analyzer by callinggetSynonymFilter()on previous filters. Returningthishere keeps prior synonym_graph filters active, so synonym rules for later filters are still expanded by earlier filters, recreating the recursive expansion/large SynonymMap problem the change is meant to prevent. This means the OOM scenario with multiple chained synonym_graph filters can still occur. Consider returningIDENTITY_FILTER(asSynonymTokenFilterFactorydoes) or otherwise disabling synonym_graph filters during synonym parsing.Useful? React with 👍 / 👎.