Hi again, I see I missed very important thing in your response. I thought I cannot reuse rewritten queries in different types of IndexReader but you wrote I cannot use rewritten queries even in another instance of IndexReader: "not even if it's a reopened reader against the same index".
I thought that I will be able to reuse the same instance of rewritten query in all MemoryIndex instances but now I see it is not possible. MemoryIndex creates new MemoryIndexReader in each createSearcher call. -- Paweł On Thu, Jul 3, 2014 at 7:40 AM, Pawel Rog <pawelro...@gmail.com> wrote: > Hi, > > 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? > > -- > Paweł > > > > On Wed, Jul 2, 2014 at 11:10 PM, Chris Hostetter <hossman_luc...@fucit.org > > wrote: > >> : 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 >> http://www.lucidworks.com/ >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org >> For additional commands, e-mail: java-user-h...@lucene.apache.org >> >> >