-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
Add the ability to dynamically update similarity options #19046
Conversation
is this breaking? i think it's just an enhancement, no? |
@clintongormley I had to change the SimilarityProvider interface which can be used in a plugin so I marked this as breaking ? It is an enhancement though but it's also a breaking change for users that have a custom similarity plugin. |
Yes this logic looks right at a glance: disallow changing NOTE: for all the lucene similarities, the index-time encoding is the same (provided But its definitely important ppl can change stuff like bm25 parameters. |
Thanks @rmuir, I want to do this in a follow up but the first step is to be able to change the similarity options. |
+1 My only suggestion for this one then, is to improve the exception if you try to change discount_overlaps: |
@s1monw I have a dynamic setting with a custom validator for the update:
My validator throws RuntimeException if the setting update is not valid. I've added a test that update my setting with invalid values: |
@jimferenczi I just added a unittest to ensure it works but it seems fine, can you point me to the test that fails? |
@s1monw thank you for checking. Here is a quick and dirty IT that should fail: It does not fail because the setting update is tested on the master with fake index scopped setting: Line 65 in 42526ac
We could retrieve the setting from the index directly but the index may not exist on the master node. |
Today all settings are only validated against their validators that are available when settings are registered. Yet, some settings updaters have validators that are dynamic ie. their validation depends on other variables that are only available at runtime. We do not run those validators when settings are updated causing index updates to fail on the data nodes instead of on the master. Relates to elastic#19046
@jimferenczi I opened #19088 for the settings problems |
Today all settings are only validated against their validators that are available when settings are registered. Yet, some settings updaters have validators that are dynamic ie. their validation depends on other variables that are only available at runtime. We do not run those validators when settings are updated causing index updates to fail on the data nodes instead of on the master. Relates to #19046
This change allows to dynamically change options for any existing similarities on an open index. This change also adds the ability to create a new similarity directly on an existing index. It does not allow to change the type of an existing similarity or to change the similarity of a field. Options are updatable only if they don't change the way the similarity encodes the norm on disk. The non-updatable options can't be changed if the index is opened nor closed. This change adds validation to the similarity settings and throws an exception with a detailed message if a setting is unknown. Relates #6727
Pushed another iteration. I updated the description with the current state. |
} | ||
} | ||
}, Property.IndexScope), // this allows similarity settings to be passed | ||
SimilarityService.SIMILARITY_SETTINGS, |
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.
does it really work to register a prefix? If yes, can you leave a comment, I think that would help since none of the other settings are registered this way
This change has a lot to do with settings, which are a bit out of my comfort zone, but the Similarity part looks good to me. I'd suggest to give another day to give Simon a chance to have a last look before merging. |
private final Similarity baseSimilarity; | ||
private final Map<String, SimilarityProvider> similarities; | ||
|
||
public static final Setting<Settings> SIMILARITY_SETTINGS = Setting.groupSetting("index.similarity.", |
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 think what we should do here is to add functionality to specify something like this:
Instead of private static final Setting<Float> LAMBDA_SETTING = Setting.floatSetting("lambda", 0.1f, Setting.Property.Dynamic);
we would add private static final Setting<Float> LAMBDA_SETTING = Setting.floatSetting("index.similarity.*.lambda", 0.1f, Setting.Property.Dynamic);
and add the ability for making this setting concrete via something like Setting#concretSetting(name)
. For the updateConsumer API I guess we must add another method that accepts the generic setting and the concrete one to pass the checks in there? @jimferenczi what do you think?
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.
Not sure how this would work. The concrete setting name and the acceptable inner settings can be resolved only when the user register a new similarity with a type like in:
index.similarity.my_similarity.type: BM25
This definition makes the settings index.similarity.my_similarity.b
and index.similarity.my_similarity.k1
acceptable.
Are you saying that we should call Setting#concreteSetting(name)
for every custom similarity that the user defines ? We would have to hack this a bit since the similarity type
is the setting that would unlock the other possible settings.
superseded by #20339 which uses the settings framework and the affix settings to achieve similar behavior. |
This change allows to dynamically change options for any existing similarities on an open index.
This change also adds the ability to create a new similarity directly on an existing index.
It does not allow to change the type of an existing similarity or to change the similarity of a field.
Options are updatable only if they don't change the way the similarity encodes the norm on disk.
The non-updatable options can't be changed if the index is opened nor closed.
This change adds validation to the similarity settings and throws an exception with a detailed message if a setting is unknown.
Relates #6727