Alas, Lucene in general does not do such structural optimization (and I agree, we should). EG we could do it during Query.rewrite().
There are certain corner cases that are handled, eg a BooleanQuery with a single BooleanClause, or BooleanQuery where minimumNumberShouldMatch exceeds the number of SHOULD clauses immediately returns no matches, etc. So in general if there are "interesting" functional equivalents of your query, you should try them out. Eg if you use filtering, you should test adding it as a clause on BooleanQuery instead of passing in the"Filter" arge to search (we are considering doing that internally). If you do some testing and learn anything interesting, please post back! Mike On Thu, May 21, 2009 at 1:06 PM, Preetham Kajekar <preet...@cisco.com> wrote: > Hi, > I am wondering if Lucene internally rewrites/optimizes Query. I am > programatically generating Query based on various user options, and quite > often I have BooleanQueri'es wrapped inside BooleanQueries etc. > Like, > ((Src:Testing Dst:Test) (Src:Test2 Port:http)). > In this case, would Lucene optimize to remove the unwanted BooleanQueries ? > Or more importantly, would these extra BooleanQueries cause any performance > problems and should I fix my code to have a better Query ? > > Thanks, > ~preetham > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org