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 Tomislav Poljak <tp...@gmail.com> on 2010/05/07 19:19:26 UTC

TermsFilter instead of "should" TermQueries

Hi,
in API documentation for TermsFilter:

http://search-lucene.com/jd/lucene/org/apache/lucene/search/TermsFilter.html

it states:

'As a filter, this is much faster than the equivalent query (a
BooleanQuery with many "should" TermQueries)'

I would like to replace "should" TermQueries with TermsFilter to benefit
in performance, but I'm trying to understand how this change/switch can
work. 

I was under the impression that the BooleanQuery with many "should"
TermQueries affects scoring like: each "should" term present in result,
increases the result's score. 

If someone could explain how can a TermsFilter (which is like any filter
a binary thing - result document is matched or not) be used to replace
should clauses, I would really appreciate it.

Tomislav


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


Re: TermsFilter instead of "should" TermQueries

Posted by Otis Gospodnetic <ot...@yahoo.com>.
I think what Tomislav was trying to ask is:

Can filters replace only strictly boolean clauses (i.e. only MUST and MUST_NOT), such as: +gender:F, -rating:xxx)?
Or can filters also replace SHOULD clauses, such as: food:banana (which is neither absolutely required or strictly prohibited)?

 Otis
----
Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch
Lucene ecosystem search :: http://search-lucene.com/



----- Original Message ----
> From: Erick Erickson <er...@gmail.com>
> To: java-user@lucene.apache.org
> Sent: Fri, May 7, 2010 8:30:18 PM
> Subject: Re: TermsFilter instead of "should" TermQueries
> 
> Well, you construct the filter by enumerating the terms you're
interested in 
> and pass it along to the relevant search.

But it looks like you've 
> figured that part out. If you're asking
how can you use a Filter and still 
> have the terms replaced
by the filter contribute to scoring, you can't. But 
> it's a reasonable
question to ask whether it changes the score enough 
> to
matter given that this is only a problem when there are 
> many
terms.

If this doesn't speak to your question, can you ask for 
> more
detail?

HTH
Erick

On Fri, May 7, 2010 at 1:19 PM, 
> Tomislav Poljak <
> href="mailto:tpoljak@gmail.com">tpoljak@gmail.com> wrote:

> 
> Hi,
> in API documentation for TermsFilter:
>
>
> 
> href="http://search-lucene.com/jd/lucene/org/apache/lucene/search/TermsFilter.html" 
> target=_blank 
> >http://search-lucene.com/jd/lucene/org/apache/lucene/search/TermsFilter.html
>
> 
> it states:
>
> 'As a filter, this is much faster than the equivalent 
> query (a
> BooleanQuery with many "should" TermQueries)'
>
> I 
> would like to replace "should" TermQueries with TermsFilter to benefit
> 
> in performance, but I'm trying to understand how this change/switch can
> 
> work.
>
> I was under the impression that the BooleanQuery with many 
> "should"
> TermQueries affects scoring like: each "should" term present in 
> result,
> increases the result's score.
>
> If someone could 
> explain how can a TermsFilter (which is like any filter
> a binary thing - 
> result document is matched or not) be used to replace
> should clauses, I 
> would really appreciate it.
>
> Tomislav
>
>
> 
> ---------------------------------------------------------------------
> To 
> unsubscribe, e-mail: 
> href="mailto:java-user-unsubscribe@lucene.apache.org">java-user-unsubscribe@lucene.apache.org
> 
> For additional commands, e-mail: 
> ymailto="mailto:java-user-help@lucene.apache.org" 
> href="mailto:java-user-help@lucene.apache.org">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


Re: TermsFilter instead of "should" TermQueries

Posted by Erick Erickson <er...@gmail.com>.
Well, you construct the filter by enumerating the terms you're
interested in and pass it along to the relevant search.

But it looks like you've figured that part out. If you're asking
how can you use a Filter and still have the terms replaced
by the filter contribute to scoring, you can't. But it's a reasonable
question to ask whether it changes the score enough to
matter given that this is only a problem when there are many
terms.

If this doesn't speak to your question, can you ask for more
detail?

HTH
Erick

On Fri, May 7, 2010 at 1:19 PM, Tomislav Poljak <tp...@gmail.com> wrote:

> Hi,
> in API documentation for TermsFilter:
>
>
> http://search-lucene.com/jd/lucene/org/apache/lucene/search/TermsFilter.html
>
> it states:
>
> 'As a filter, this is much faster than the equivalent query (a
> BooleanQuery with many "should" TermQueries)'
>
> I would like to replace "should" TermQueries with TermsFilter to benefit
> in performance, but I'm trying to understand how this change/switch can
> work.
>
> I was under the impression that the BooleanQuery with many "should"
> TermQueries affects scoring like: each "should" term present in result,
> increases the result's score.
>
> If someone could explain how can a TermsFilter (which is like any filter
> a binary thing - result document is matched or not) be used to replace
> should clauses, I would really appreciate it.
>
> Tomislav
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>