Skip to content

Synonyms API - Add refresh parameter to check synonyms index and reload analyzers #126935

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
wants to merge 41 commits into
base: main
Choose a base branch
from

Conversation

carlosdelest
Copy link
Member

@carlosdelest carlosdelest commented Apr 16, 2025

Closes #121441

Synonyms APIs use a system index to store synonyms as individual documents. These documents need to be searched in order to be retrieved from the analyzers.

When the system index has not been created yet, it is possible that creating the index need some time for the replicas to be available for search. Thus, an analyzer that is reloaded after the synonyms are created won't be able to retrieve the synonyms, and as a consequence we won't have synonyms for the index until a reload analyzer operation is performed.

This PR fixes this issue by adding a refresh parameter to the following APIs:

  • Update synonyms set
  • Update synonym rule
  • Delete synonym rule

When refresh is true, after updating the synonyms system index, the following operations will be executed:

  • Wait for the synonyms index health to be green (meaning that it's searchable from the search analyzers)
  • Refresh the search analyzers so they are updated with the new synonyms.

refresh is true by default to maintain the previous behaviour. When refresh is true, reload analyzers information will be included in the response.

…-searchable-refresh

# Conflicts:
#	server/src/main/java/org/elasticsearch/TransportVersions.java
@carlosdelest carlosdelest added :Search Relevance/Analysis How text is split into tokens Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch labels Apr 16, 2025
ENTRY_PARSER.declareStringArray(constructorArg(), ReloadAnalyzersResponse.RELOADED_NODE_IDS_FIELD);
ENTRY_PARSER.declareStringArray(constructorArg(), ReloadAnalyzersResponse.RELOADED_ANALYZERS_FIELD);
Copy link
Member Author

Choose a reason for hiding this comment

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

There was a bug in the parsing method in the tests for ReloadAnalyzerResponseTests 🤯


public class SynonymUpdateResponseSerializingTests extends AbstractWireSerializingTestCase<SynonymUpdateResponse> {
public class SynonymUpdateResponseSerializingTests extends AbstractBWCSerializationTestCase<SynonymUpdateResponse> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Adding BWC serialization compat testing

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

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

:shipit:

@elasticsearchmachine
Copy link
Collaborator

Hi @carlosdelest, I've created a changelog YAML for you.

…-searchable-refresh

# Conflicts:
#	server/src/main/java/org/elasticsearch/TransportVersions.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search Relevance/Analysis How text is split into tokens serverless-linked Added by automation, don't add manually Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Synonyms API - Ensure system index is available when updating synonyms
3 participants