-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat(search): De-duplicate scale factors across entities #8718
Conversation
|
Collectors.mapping(annotation -> annotation, | ||
Collectors.toList()))); | ||
|
||
for (Map.Entry<String, List<SearchableAnnotation>> annotationEntry : annotations.entrySet()) { |
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.
Hmm, can't this just be changed in the lambda that's currently in the flatMap call? As in instead of streaming across all of them just pull the first one and calculate the weight factor? Doing an intermediate collect complicates the readability and is relatively expensive.
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.
To deduplicate equivalent values in the stream you can use distinct()
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.
Yeah, I can do that! This is how it's done above but I'll rewrite it to do that (and maybe the one above too)
We have scales, such as downweighting deprecated entities, that are applied on multiple indices. Previously, when we were querying only one index at a time, only one of these would be applied at once, but now that we query multiple indices together, we have no de-duplicating logic. Therefore, the scales are being applied multiple times. This change is to de-duplicate the scale factors.
Tested locally on quickstart (since our test entity registry does not have these set up)
function scores section before the change:
Functions section after the change:
Checklist