I would like to incorporate a decay function based off of a time field attached to a vector when conducting a KNN search. I am using the Kotlin client. WIth a regular query, this would be done through the function score builder, but knn does not seem to expose any such API. Is this possible?
Hi there @Yevgeny_Yurgenson - if you're using Elasticsearch 8.12 or higher, you could check out the knn query. This allows you to search with knn
just as with any query type in our query DSL and you should be able to combine this just like any other query type - in boolean queries, with rescores, etc.
The goal is to rescore the KNN vectors returned from the KNN search based on some other field parameter. For example, if i have two vectors that both have similarity scores of .8, but one of them is a year old, i would like it to be penalized by .4, so that my resulting scores are .8 and .4.
This is trivial to do with a regular query, but KNN does not seem to have a rescoring ability, nor does it seem to have the ability to attach a custom scoring script. If I am mistaken, could you please demonstrate code that would accomplish this?
Hi, the KNN query that I linked above is a different syntax than a regular top level knn search. This is an actual query included in the regular query structure. Please give that a try and if you are still running into difficulties please provide an example that we can reproduce. Thank you.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.