lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pawel Rog <>
Subject Re: Query rewriting - caching rewritten quries
Date Thu, 03 Jul 2014 05:40:13 GMT

Thank you for your response Chris. I see good news that I can pre-build
rewritten queries for a given IndexReader and then use it in the same
IndexReader. Can you tell me how I can achieve this?

I see each Query has rewrite method which takes IndexReader as an argument.
The only thing is just to call this method, save the result and then use
this result instead of the original query?


On Wed, Jul 2, 2014 at 11:10 PM, Chris Hostetter <>

> : In the system which I develop I have to store many query objects in
> memory.
> : The system also receives documents. For each document MemoryIndex is
> : instantiated. I execute all stored queries on this MemoryIndex. I
> realized
> : that searching over MemoryIndex takes much time for query rewriting. I'm
> : wondering if I can cache rewritten queries to avoid still rewritting. Is
> : there any way to do it?
> it depends on what you want to do with the cached queries.
> the rewritten queries are relative to the IndexReader passed to the
> rewrite() method -- you can't re-use them against a new/different
> IndexReader (not even if it's a reopened reader against the same index)
> from a memory standpoint, rewritten queries also tend to be larger then
> the original query (due to term expansion) so even if you plan on using
> these cached queries over and over against hte same IndexReader
> (allthough: there's not much point of that -- you might as wel ust cache
> the results instead) you're trading the time needed for rewrite() against
> the the memory needed for the cache.
> -Hoss
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message