You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by sol myr <so...@yahoo.com> on 2011/10/25 14:18:13 UTC

"AND" Query "under the hood" ?

Hi,

Could I please ask another question regarding Lucene "under the hood" / performance.

I wondered how "AND" queries are implemented?
Say we query for "+hello +world".
Would Lucene simply find 2 lists of documents ("documents containing HELLO",  and "documents containing WORLD"), 

and then intersect them (yielding documents with both words)?
Or does Lucene do smarter tricks? 


And in regards to performance, is there any importance to query order ( "+hello +world"  as opposed to "+world +hello")?


Thanks :)


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: "AND" Query "under the hood" ?

Posted by Simon Willnauer <si...@googlemail.com>.
On Tue, Oct 25, 2011 at 2:18 PM, sol myr <so...@yahoo.com> wrote:
> Hi,
>
> Could I please ask another question regarding Lucene "under the hood" / performance.
>
> I wondered how "AND" queries are implemented?
> Say we query for "+hello +world".
> Would Lucene simply find 2 lists of documents ("documents containing HELLO",  and "documents containing WORLD"),
>
> and then intersect them (yielding documents with both words)?
> Or does Lucene do smarter tricks?

this is basically what happens under the hood. On trunk we optimize BQ
that are composed from TermQueries. Lucene uses the Term with the
lowest frequency to lead the intersection. (LUCENE-3328) For other
queries we try predict the sparseness of a scorer / query to lead the
intersection.
>
>
> And in regards to performance, is there any importance to query order ( "+hello +world"  as opposed to "+world +hello")?

there might be situations where our sparse predictions are failing so
there the order might matter, for termqueries on trunk it doesn't

simon
>
>
> Thanks :)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org