-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Auto-reload analyzers for specific resource #96986
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
Auto-reload analyzers for specific resource #96986
Conversation
Pinging @elastic/es-search (Team:Search) |
3fbe5df
to
bc2d21b
Compare
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.
LGTM! 🚀
I think it would be less confusing (and have less code changes) if we don't pass null
explicitly. We might create methods / constructors that have the synonymSetId as parameter, or not (and thus invoke internally the other method with null
).
...alysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java
Outdated
Show resolved
Hide resolved
*/ | ||
public ReloadAnalyzersRequest(String... indices) { | ||
public ReloadAnalyzersRequest(String resource, String... indices) { |
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.
Should we add another constructor that does not have resource
as parameter, to avoid passing null
?
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.
I explored this, but this is not possible as indices is varargs of the same type of String.
Making two constructors, and doing ReloadAnalyzersRequest(resource1, index1)
throws an error:
reference to ReloadAnalyzersRequest is ambiguous
| both constructor ReloadAnalyzersRequest(java.lang.String...).. and constructor ReloadAnalyzersRequest(java.lang.String,java.lang.String...) ... match
...s-common/src/main/java/org/elasticsearch/analysis/common/SynonymGraphTokenFilterFactory.java
Show resolved
Hide resolved
match: | ||
my_field: | ||
query: salute | ||
- match: { hits.total.value: 1 } |
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.
Great test! 💯
Is it too redundant to query the other index to ensure nothing changed?
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.
Addressed in de85b76. But indeed looks redundant as we did not change the synonyms set that other index is based on.
server/src/main/java/org/elasticsearch/action/admin/indices/analyze/ReloadAnalyzersRequest.java
Show resolved
Hide resolved
@@ -95,7 +95,7 @@ default NamedAnalyzer getDefaultSearchQuoteAnalyzer() { | |||
/** | |||
* Reload any analyzers that have reloadable components | |||
*/ | |||
default List<String> reload(AnalysisRegistry analysisRegistry, IndexSettings indexSettings) throws IOException { | |||
default List<String> reload(AnalysisRegistry analysisRegistry, IndexSettings indexSettings, String resource) throws IOException { |
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.
Should we add another method that has no resource
on it, to avoid invoking this with explicit null
s?
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.
We never call it with explicit "null", so having a single constructor is enough.
bc2d21b
to
f68df16
Compare
@elasticsearchmachine run elasticsearch-ci/part-1 |
Thanks for the changes, Mayya! LGTM 👍 |
This PR adds a new optional parameter "resource" for ReloadAnalyzersRequest. If used, only analyzers that use this specific "resource" will be reload. This parameter is not documented, for internal use only. PR elastic#96886 introduced auto-reload of analyzers on synonyms index change. The problem was that reloading was applied broady for all indices that contained reloadable analyzers. This PR improves this, so when a particular synonyms set changes, only analyzers that use this synonyms set will auto-reloaded. Note that shard requests will still be sent to all indices shards, as only on a shard we can decide if analyzers need to be reloaded.
f68df16
to
30a2562
Compare
This PR adds a new optional parameter "resource" for ReloadAnalyzersRequest.
If used, only analyzers that use this specific "resource" will be reloaded.
This parameter is not documented, for internal use only.
PR #96886 introduced auto-reload of analyzers on synonyms index change. The problem
was that reloading was applied broadly for all indices that contained any reloadable
analyzers. This PR improves on it, so when a particular synonyms set changes,
only analyzers that use this synonyms set will auto-reloaded. Note that shard
requests will still be sent to all indices shards, as only on a shard we can
decide if analyzers need to be reloaded.