lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: Differences between BooleanQuery and QueryParser
Date Mon, 30 Jan 2012 23:22:47 GMT
The parsing will be a trivial part of the overall
query time, so small that I wouldn't worry about
it in the least. I'd concentrate on doing the thing that
takes the least maintenance.

In the examples you're positing, it's not at all clear you
could even measure the difference...

Do what's easiest, *then* optimize if necessary...

Best
Erick

On Mon, Jan 30, 2012 at 5:38 PM, Felipe Carvalho
<felipe.carvalho@gmail.com> wrote:
> Has anyone ever measured the difference? Could it make a 10%+ difference on
> a search involving around 5 terms?
>
> On Mon, Jan 30, 2012 at 8:05 PM, Brandon Mintern <mintern@easyesi.com>wrote:
>
>> A QueryParser has to actually parse your text and build up the
>> BooleanQuery exactly as you do in your second example. Since the
>> QueryParser is doing extra work that you don't have to do considering
>> that you already know everything about the query, your second example
>> is faster.
>>
>> On Mon, Jan 30, 2012 at 1:55 PM, Felipe Carvalho
>> <felipe.carvalho@gmail.com> wrote:
>> > Is there any difference, from a performance standpoint (or any other
>> > standpoint whatsoever), between instantiating a query using QueryParser
>> and
>> > BooleanQuery? Is either of them preferable to use?
>> >
>> > Eg:
>> >
>> > QueryParser parser = new QueryParser(Version.LUCENE_33, "name", wrapper)
>> > Query query = parser.parse("size:small AND color:blue")
>> >
>> > versus
>> >
>> > BooleanQuery skuQuery = new BooleanQuery();
>> > skuQuery.add(new TermQuery(new Term("size", "small")), Occur.MUST);
>> > skuQuery.add(new TermQuery(new Term("color", "blue")), Occur.MUST);
>> >
>> >
>> > 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


Mime
View raw message