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

Simon Willnauer commented on LUCENE-2868:
-----------------------------------------

{quote}
When you have the same query in a query hierarchy multiple times, tremendous 
savings can now be had if the user knows enough to share the rewritten queries 
in the hierarchy, due to the TermCache addition. But this is clumsy and 
requires a lot of coding by the user to take advantage of. Lucene should be 
smart enough to share the rewritten queries automatically.
{quote}

First of all, I get nervous when it gets to stuff like this! Hence, I can see 
when this could be useful, for instance if you have one and the same FuzzyQuery 
/ RegexpQuery which has a rather large setup cost in more than one clause in a 
boolean query then this would absolutely help. For other queryies like 
TermQuery the TermState cache in TermsEnum already helps you a lot so for those 
this wouldn't make a big difference though. 

bq. Query rewriteUsingCache(IndexReader indexReader)
I think one major issue here is how would you clear a cache here. 
WeakReferences would work but I would't  to put any cache into any query. In 
general we shouldn't make any query heavy weight or "somewhate stateful" at 
all. Yet, if we would pass a RewriteCache into Query#rewrite(IR, RC) that has a 
per IS#search lifetime this could actually work. This would also be easy to 
implement Query#rewrite(IR, RC) would just forward to Query#rewrite(IR) for by 
default and combining (BooleanQuery) queries could override the new one. 
Eventually, MultiTermQuery can provide such an impl and check the cache if it 
needs to rewrite itself or return an already rewritten version.

> It should be easy to make use of TermCache; rewritten queries should be 
> shared automatically
> --------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-2868
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2868
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Query/Scoring
>            Reporter: Karl Wright
>
> When you have the same query in a query hierarchy multiple times, tremendous 
> savings can now be had if the user knows enough to share the rewritten 
> queries in the hierarchy, due to the TermCache addition.  But this is clumsy 
> and requires a lot of coding by the user to take advantage of.  Lucene should 
> be smart enough to share the rewritten queries automatically.
> This can be most readily (and powerfully) done by introducing a new method to 
> Query.java:
> Query rewriteUsingCache(IndexReader indexReader)
> ... and including a caching implementation right in Query.java which would 
> then work for all.  Of course, all callers would want to use this new method 
> rather than the current rewrite().

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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

Reply via email to