Well... scoring of AND queries currently is done doc-at-once. So Lucene will first step to doc 1 for Name, then ask age to skip to doc >= 1, will see that both have doc=1 and collect it. The same thing happens for doc=2. Then, Lucene will ask for the next doc of Name, which returns "false" (end of docs) and the loop breaks.
OR, Lucene may drive the query in the opposite order (age and then Name), in which case it's the same through doc=2, but then Lucene asks age for the next doc, gets 5 back, then asks the Name iter to skip to doc >= 5, which returns false, and the loop breaks. So in fact "doc=5" can be asked for by Lucene. Also note that this is an internal implementation detail -- Lucene could easily change to do batch processing of AND'd queries in which case docs 5,10 could easily be iterated on. So I wouldn't "rely" on this in your app. Mike On Thu, May 21, 2009 at 10:34 AM, Joel Halbert <j...@su3analytics.com> wrote: > Thx. so, just to clarify, in the example I gave below... > > Lucene will search for documents matching on Name and find doc 1 and doc > 2. > Then it will search age and find docs 1, 2 and then break. It will not > go on to seek 5 and 10...? > > -----Original Message----- > From: Michael McCandless <luc...@mikemccandless.com> > Reply-To: java-user@lucene.apache.org > To: java-user@lucene.apache.org > Subject: Re: Does Lucene fail fast on boolean queries? > Date: Thu, 21 May 2009 10:29:57 -0400 > > Yes. > > As soon as Lucene sees that the Name docID iteration has ended, the > search will break. > > Mike > > On Thu, May 21, 2009 at 8:44 AM, Joel Halbert <j...@su3analytics.com> wrote: >> Hi, >> >> When Lucene performs a Boolean query, say: >> >> Field Name = Male >> AND >> Field Age = 30 >> >> assuming the resultant docs for each portion of the query were: >> >> Matching docs for: Name = 1,2 >> Matching docs for: Age = 1,2,5,10 >> >> Will Lucene stop searching for documents matching the Age term once it >> has found documents 1 and 2 ? >> i.e. since 5 and 10 will not be used will it stop searching at document >> number 2 ? >> >> Thx, >> Joel >> >> >> --------------------------------------------------------------------- >> 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 > > > > --------------------------------------------------------------------- > 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