You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Rasik Pandey <ra...@ajlsm.com> on 2004/02/25 15:39:28 UTC

RE : BooleanQuery/Clauses with Linked Filters

> On Feb 25, 2004, at 6:48 AM, Rasik Pandey wrote:
> > I was wondering if it is somehow possible to tie filters to
> individual
> > boolean queries/clauses. I didn't see any such possibility
> with a
> > quick inspection of the code and I am not sure if a special
> > HitCollector implementation would be sufficient or even
> merited. Any
> > ideas, suggestions, or comments would be appreciated.
> 
> I'm not following what you mean.  Could you describe a concrete
> example
> of what you're after?

Searching Lucene with a BooleanQuery using Searcher.search(Query query, Filter filter) does not allow for coupling filters to sub-queries of the BooleanQuery, but rather coupling a filter to the parent BooleanQuery.


Currently we can do this:

BooleanQuery not Filter(state, texas) not Filter(country, georgia)
-TermQuery(city, paris) 
OR
-TermQuery(state, georgia)


instead we would like to be able to do this.
BooleanQuery 
-TermQuery(city, paris) not Filter(state, texas)
OR
-TermQuery(state, georgia) not Filter(country, georgia)


Let me know if this isn't clear.

RBP



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


Re: RE : RE : BooleanQuery/Clauses with Linked Filters

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Feb 25, 2004, at 11:51 AM, Rasik Pandey wrote:
> Our particular case concerns adding or doing a "date query" for which 
> we are using a DateFilter. We were using a DateFilter to represent one 
> of the nested sub-queries, but since that is only possible at the same 
> level of a complex parent BooleanQuery, this obviously would affect 
> the results globally instead of respecting the nesting.  Maybe the 
> answer is the RangeQuery? I need to research that....

Yeah, RangeQuery sounds like the right thing to do in your case.

> In general, what is the performance gain, if any, when using a Filter 
> vs. adding an extra BooleanClause to retrieve the same results?

I'm not sure it can be generalized - it would depend on the query and 
the filter you're comparing.  But generally a Filter has upfront work 
to do to create the filter bit set.  For a DateFilter, this involves 
enumerating the terms in the range.  The QueryFilter performs an actual 
query, so it would be dependent on what it needed to do.

Filters are good when you can create them and let them live over the 
the course of multiple queries.

	Erik


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


RE : RE : BooleanQuery/Clauses with Linked Filters

Posted by Rasik Pandey <ra...@ajlsm.com>.
> Its still not entirely clear, but it seems you could accomplish
> what
> you want by putting in some AND TermQuery's in there instead of
> trying
> to use a Filter.  Wouldn't that do what you want?

Ok so the example wasn't as concrete as it should have been and you are right about the fact that I could add some more sub-queries to get the same effect. 

Our particular case concerns adding or doing a "date query" for which we are using a DateFilter. We were using a DateFilter to represent one of the nested sub-queries, but since that is only possible at the same level of a complex parent BooleanQuery, this obviously would affect the results globally instead of respecting the nesting.  Maybe the answer is the RangeQuery? I need to research that....

In general, what is the performance gain, if any, when using a Filter vs. adding an extra BooleanClause to retrieve the same results?


RBP 



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


Re: RE : BooleanQuery/Clauses with Linked Filters

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Feb 25, 2004, at 9:39 AM, Rasik Pandey wrote:
>> On Feb 25, 2004, at 6:48 AM, Rasik Pandey wrote:
>>> I was wondering if it is somehow possible to tie filters to
>> individual
>>> boolean queries/clauses. I didn't see any such possibility
>> with a
>>> quick inspection of the code and I am not sure if a special
>>> HitCollector implementation would be sufficient or even
>> merited. Any
>>> ideas, suggestions, or comments would be appreciated.
>>
>> I'm not following what you mean.  Could you describe a concrete
>> example
>> of what you're after?
>
> Searching Lucene with a BooleanQuery using Searcher.search(Query 
> query, Filter filter) does not allow for coupling filters to 
> sub-queries of the BooleanQuery, but rather coupling a filter to the 
> parent BooleanQuery.

right - you cannot apply filters to subqueries.  A filter is really a 
pre-query screen, not really part of the query itself.

> Currently we can do this:
>
> BooleanQuery not Filter(state, texas) not Filter(country, georgia)
> -TermQuery(city, paris)
> OR
> -TermQuery(state, georgia)
>
>
> instead we would like to be able to do this.
> BooleanQuery
> -TermQuery(city, paris) not Filter(state, texas)
> OR
> -TermQuery(state, georgia) not Filter(country, georgia)
>
>
> Let me know if this isn't clear.

Its still not entirely clear, but it seems you could accomplish what 
you want by putting in some AND TermQuery's in there instead of trying 
to use a Filter.  Wouldn't that do what you want?

	Erik


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