-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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 a score_mode to the rescore #3258
Comments
Here my commit: hc@c37a2b7 |
This looks very useful. I will look into this asap... catching up right now after 3 weeks of absence :) |
I added a comment, can you update the PR? |
any news on the PR? |
I was also in holidays the past weeks :) I will push it later today. |
cool man I will look soon / tomorrow thanks :) |
this looks really good. One minor thing, since those functions are idempotent can we only create one instance for them and keep it around and then do PS: I hope you had a good vacation :) |
You are definitely right, I added a commit: #3360 PS: thanks! You too if that's also the reason of your absence :) |
how about making the score functions simply an enum? |
Do you mean something like: private static enum ScoreMode {
Avg("avg of:"),
Max("max of:"),
Min("min of:"),
Multiply("product of:"),
Total("sum of:");
private final String description;
ScoreMode(String description) {
this.description = description;
}
public float combine(float primary, float secondary) {
switch (this) {
case Avg:
return (primary + secondary) / 2;
case Max:
return Math.max(primary, secondary);
case Min:
return Math.min(primary, secondary);
case Multiply:
return primary * secondary;
case Total:
default:
return primary + secondary;
}
}
public String description() {
return description;
}
} |
the combine method can be abstract on the enum, and each actual enum value can implement it, then you won't need the switch statement. |
Oh thanks I didn't know about that. I pushed the modification. |
@hc looks good can you squash the commits? |
Default value is "total", possible values are: "max", "min", "avg", "multiply" and "total". - "total": the final score of a document is the sum of the original query score with the rescore query score. - "max": only the highest score count. - "min": only the lowest score is kept (if the document doesn't match the rescore query, the original query score is used). - "avg": average of both scores - "multiply": product of both scores Closes elastic#3258
I updated the PR |
Default value is "total", possible values are: "max", "min", "avg", "multiply" and "total". - "total": the final score of a document is the sum of the original query score with the rescore query score. - "max": only the highest score count. - "min": only the lowest score is kept (if the document doesn't match the rescore query, the original query score is used). - "avg": average of both scores - "multiply": product of both scores Closes #3258
@hc thanks man! would you mind opening an issue on the doc repo to update the features documentation? |
Default value is "total", possible values are: "max", "min", "avg", "multiply" and "total". - "total": the final score of a document is the sum of the original query score with the rescore query score. - "max": only the highest score count. - "min": only the lowest score is kept (if the document doesn't match the rescore query, the original query score is used). - "avg": average of both scores - "multiply": product of both scores Closes elastic#3258
I started working on adding a score_mode parameter to the rescore query, something like :
Default is "total", possible values are : avg, max, min, total and multiply.
My use case is for the "multiply", because I want to do something like:
So rather than having to duplicate my complex query in the rescore query, I just multiply the first score with the second one.
What do you think? I will post my code.
The text was updated successfully, but these errors were encountered: