Skip to content

Conversation

@laminelam
Copy link
Contributor

@laminelam laminelam commented Sep 7, 2025

This PR fixes the "synonym_graph filter fails with word_delimiter_graph when using whitespace or classic tokenizer in synonym_analyzer" bug

Investigated the issue and looks like there are 2 causes:

  • When building the analyzers, if one fails for some reason, it throws an exception and the process stops. So the customSynonymAnalyzer does not get instantiated.
  • On the other hand, if the customSynonymAnalyzer depends on another one that hasn't been built (and registred) yet the process fails too.

analysisRegistry.getAnalyzer(synonymAnalyzerName);

This is not enough because it only looks into the built in and pre built in analyzers. The one from settings are not there.

The solution is two-fold:

  • Fail safe instead of fail fast when building the analyzers.
  • Build the depending analyzers first.

Fail safe instead of fail fast when building the analyzers
Right now, if an analyzer fails for some reason the whole building process fails with an exception.

Build the depending analyzers first:
Synonym custom analyzers may depend on another analyzer that has to be built first.
The PR adds a logic to:

  • add option "order" attribute that defines precedence order between analyzers
  • add 'analyzersBuiltSoFar' to getChainAwareTokenFilterFactory to pass the already built analyzers needed by the one being built

Resolves #18037

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.

…whitespace or classic tokenizer in synonym_analyzer" bug opensearch-project#18037

add 'analyzersBuiltSoFar' to getChainAwareTokenFilterFactory to build custom analyzers depending on other (already built) analyzers
The analyzers are built following the order of precedence specified in the settings

Signed-off-by: Lamine Idjeraoui <[email protected]>
@github-actions github-actions bot added bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing labels Sep 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2025

❌ Gradle check result for 5c8fbe6: 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?

@laminelam
Copy link
Contributor Author

@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2025

❌ Gradle check result for 267f48e: 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

@gaobinlong gaobinlong left a comment

Choose a reason for hiding this comment

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

The DCO check is failed, please amend your commit with '-s' to include the sign off info, and change log is needed.

List<TokenFilterFactory> previousTokenFilters,
Function<String, TokenFilterFactory> allFilters
Function<String, TokenFilterFactory> allFilters,
Function<String, Analyzer> analyzersBuiltSoFar
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is breaking because the method is public, do we have another solution?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @gaobinlong
Do you have time to finish the review?

@prudhvigodithi
Copy link
Member

Thanks @laminelam looks like similar issue from past #16263 (comment) ?

@github-actions
Copy link
Contributor

❌ Gradle check result for 48cc847: 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?

@laminelam
Copy link
Contributor Author

Thanks @laminelam looks like similar issue from past #16263 (comment) ?

Yes I think they are related. This fix should handle both situations

Copy link
Member

@andrross andrross left a comment

Choose a reason for hiding this comment

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

@prudhvigodithi Can you review this PR since you've worked on a similar issue in the past?

@github-actions
Copy link
Contributor

❌ Gradle check result for 49bb330: 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?

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

Labels

bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] synonym_graph filter fails with word_delimiter_graph when using whitespace or classic tokenizer in synonym_analyzer – similar to #16263

4 participants