[ 
https://issues.apache.org/jira/browse/LUCENE-10276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17453066#comment-17453066
 ] 

Adrien Grand commented on LUCENE-10276:
---------------------------------------

KnnVectorQuery rewrites into a query that produces fixed scores but a small set 
of doc IDs. Unfortunately the query cache works on the rewritten query, so what 
would get cached would be the results of that second query, not the 
KnnVectorQuery.

You could create a query that computes the top-k nearest neighbors on a 
per-segment basis (since the query cache is per-segment) but I'm not sure how 
useful that would be since every small segments would likely produce weak 
results.

If you want to cache the results of nearest-neighbor search, I fear that you 
would need a different cache, e.g. at the reader level (LeafReader wrapper that 
caches the results of searchNearestNeighbors) or at the application level.

> Turning LRUQueryCache On selectively for only a few query classes
> -----------------------------------------------------------------
>
>                 Key: LUCENE-10276
>                 URL: https://issues.apache.org/jira/browse/LUCENE-10276
>             Project: Lucene - Core
>          Issue Type: Task
>            Reporter: Angadpreet Nagpal
>            Priority: Minor
>
> Hi,
> I'm part of the Amazon Lucene team. I was trying to get KNN queries to work 
> with LRUQueryCache. From my understanding, if I have isCacheable to return 
> true from my query class then it will taken care of. However, I want Lucene 
> to only turn on the cache for KNN only and not for any other query like 
> TermQuery, etc which might also be returning true for the isCacheable method. 
> Is there any easy interface which would allow me to do this without having to 
> go into each individual query class and returning false for the isCacheable  
> for all of them or having to write my own cache class. Any help would be 
> appreciated.
> Please correct me if I have incorrectly assumed something. This is my first 
> issue!
>  
> Thanks,
> Angadpreet Nagpal



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to