Allow different decay values depending on the score function#91195
Conversation
|
Pinging @elastic/es-search (Team:Search) |
benwtrent
left a comment
There was a problem hiding this comment.
I think the change is mostly good. It clarifies the mathematical restrictions within the validations.
I mentioned one change required. We should only have a separate decay validator.
Additionally, It would be good to add some test lines to ScoreFunctionBuilderTests:
Something along the lines
expectThrows(IllegalArgumentException.class, () -> new ExponentialDecayFunctionBuilder("", "", "", "", 0.0));
expectThrows(IllegalArgumentException.class, () -> new ExponentialDecayFunctionBuilder("", "", "", "", 1.0));
expectThrows(IllegalArgumentException.class, () -> new GaussDecayFunctionBuilder("", "", "", "", 0.0));
expectThrows(IllegalArgumentException.class, () -> new GaussDecayFunctionBuilder("", "", "", "", 1.0));
expectThrows(IllegalArgumentException.class, () -> new LinearDecayFunctionBuilder("", "", "", "", 1.0));
expectThrows(IllegalArgumentException.class, () -> new LinearDecayFunctionBuilder("", "", "", "", -1.0));
// should not throw
LinearDecayFunctionBuilder("", "", "", "", 0.0);| /** | ||
| * Validate properties, override this function if you have different validation rules per score function | ||
| */ | ||
| protected void validateProperties(String fieldName, Object scale, double decay){ |
There was a problem hiding this comment.
This could simply be a validateDecay function. The null checks will always be universal.
But, I think this idea of a protected/Overridable function is a good one.
There was a problem hiding this comment.
@benwtrent Thanks for the comments! will work on it 💪
|
jenkins test this please |
benwtrent
left a comment
There was a problem hiding this comment.
Once CI is ✅ I will give it a merge.
Thank you for your contribution!
|
@matiassalles99 please run One day maybe we will just auto apply formatting via a workflow. But not yet :). |
|
Sure! |
|
@elasticmachine update branch |
|
jenkins test this please |
|
🎉 🎉 🎉 🎉 |
* main: (1300 commits) update c2id/c2id-server-demo docker image to support ARM (elastic#91144) Allow legacy index settings on legacy indices (elastic#90264) Skip prevoting if single-node discovery (elastic#91255) Chunked encoding for snapshot status API (elastic#90801) Allow different decay values depending on the score function (elastic#91195) Fix handling indexed envelopes crossing the dateline in mvt API (elastic#91105) Ensure cleanups succeed in JoinValidationService (elastic#90601) Add overflow behaviour test for RecyclerBytesStreamOutput (elastic#90638) More actionable error for ancient indices (elastic#91243) Fix APM configuration file delete (elastic#91058) Clean up handshake test class (elastic#90966) Improve H3#hexRing logic and add H3#areNeighborCells method (elastic#91140) Restrict direct use of `ApplicationPrivilege` constructor (elastic#91176) [ML] Allow NLP truncate option to be updated when span is set (elastic#91224) Support multi-intersection for FieldPermissions (elastic#91169) Support intersecting multi-sets of queries with DocumentPermissions (elastic#91151) Ensure TermsEnum action works correctly with API keys (elastic#91170) Fix NPE in auditing authenticationSuccess for non-existing run-as user (elastic#91171) Ensure PKI's delegated_by_realm metadata respect run-as (elastic#91173) [ML] Update API documentation for anomaly score explanation (elastic#91177) ... # Conflicts: # x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java # x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/RollupShardIndexer.java # x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/TransportRollupIndexerAction.java # x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/RollupActionSingleNodeTests.java
Tackles #78887
Currently, when setting a decay value on a score function, you can only set a value between 0 and 1 exclusively, independently of the score function you're using.
This makes sense with gauss and exp score functions, since they use ln(decay) in their formula, and ln(0) does not exist.

But when using linear functions the decay should be allowed to be 0, since the formula would not result in a division by 0.
I'm open to any suggestions on how to tackle it better or test it better