This post explains why Lucene doesn't cache all queries:
https://www.mail-archive.com/java-user@lucene.apache.org/msg51649.html

Your queries could be skipping the cache because of the LRUQueryCache
constructor parameters, or because of the QueryCachingPolicy.shouldCache
predicate. They probably have sensible default behavior already, but if you
need to change the behavior for your benchmark then you can try tuning
these to make your queries cached.

Best,
Yixun Xu

On Tue, Jul 2, 2024 at 9:26 AM Δημήτρης Κλειναυτάκης <mimisk...@gmail.com>
wrote:

> Hi all,
> I am using the Lucene 9.6 version and I am trying to add queries into
> LRUQueryCache from my benchmarks that evaluate the queries and create the
> LRUQueryCache. First, I believed that Lucene puts the queries by default
> into queryCache but that was never the case. So, I read the LRUQueryCache
> API and then noticed that putIfAbsent method that puts the queries into
> queryCache is never called from Lucene and is assigned as private, so I
> can't call it from my benchmarks. I am thinking if there is another way to
> add queries into LRUQueryCache that I don't know. I will be thankful if
> someone can explain or help  me on this, If it is possible to add queries
> into LRUQueryCache outside of Lucene or if my approach is wrong.
>
> My code that creates and sets the queryCache into benchmarks :
>
> LRUQueryCache queryCache = new LRUQueryCache(40000, 1 * 1024 * 1024 *
> 1024);
> QueryCachingPolicy cachingPolicy = new UsageTrackingQueryCachingPolicy();
> IndexSearcher searcher = new IndexSearcher(reader);
> searcher.setQueryCache(queryCache);
> searcher.setQueryCachingPolicy(cachingPolicy);
>
>
> Thanks in advanced
>
> Dimitris Klinaftakis
>

Reply via email to