Perform nearest neighbors search from Painless script? #368
Replies: 6 comments
-
I think it's possible. In a very very early version I was actually using Painless directly in the plugin. It's not very efficient but has its place at times. Can you give more detail on how you'd like to use it? For example, do you want to just have access to the raw vector values? It should be possible to support the same or similar interface that Elasticsearch provides to its native vectors. I'm pretty sure I actually did this at one point early on so hopefully I can dig through the git history and find it. I'm trying to think of a different usecase or different type of operation on vectors in a script, but struggling. Let me know what you think. |
Beta Was this translation helpful? Give feedback.
-
Yeah, let's back up and talk about what I'm trying to do. You might have better suggestions. Basically I want to combine your stuff (a score based on cosine similarity of vectors) with filters, and I want it to be efficient. Some observations:
What I've noticed is that the performance doesn't really depend on how many documents match the filter. It looks like Elasticsearch is evaluating elasticknn_nearest_neighbors on all the documents, regardless of whether they satisfy the filter. That's an inference based on all the timings being the same.
Maybe you have better suggestions. |
Beta Was this translation helpful? Give feedback.
-
Yeah that seems like a bug internally. The "correct" thing to do here would be to make sure only the filtered vectors get evaluated. |
Beta Was this translation helpful? Give feedback.
-
I guess even if we solve the issue of evaluating all vectors, it won't get around this issue. Will take that into consideration. |
Beta Was this translation helpful? Give feedback.
-
As I think about it more, this issue may not be a total blocker for us (the fact that only 10,000 results can be rescored). If I could get rescore queries working with elastiknn, that would be very useful. |
Beta Was this translation helpful? Give feedback.
-
Hi @ejackson-eb . I'm gonna close this just to tidy up a bit. Please comment and tag me if you'd like to discuss more and I'll re-open. |
Beta Was this translation helpful? Give feedback.
-
I think this is a feature request, but maybe it is already possible..
I would like to be able to perform a nearest neighbors search from a Painless script (within a function_score query). Is this possible?
Beta Was this translation helpful? Give feedback.
All reactions