Thanks your kind help Erik..........
-----Original Message-----
From: Erik Hatcher [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 07, 2004 12:56 PM
To: Lucene Users List
Subject: Re: Filter !!!
On Dec 7, 2004, at 12:55 AM, Chris Hostetter wrote:
>
> : Hits hits = indexSearcher.search(searchQuery, filter) // here I
> want
> : to pass multiple filter... (DateFilter,QueryFilter)
>
> You can write a Filter that takes in multiple filters and ANDs them
> together (or ORs them, it's not clear what you want)
>
> Hits h = s.search(q,new AndFilter(df,qf));
> (I'm planing on writting a generalized "BooleanFilter" class sometime
> in the next few weeks)
Wait.... there already is a ChainedFilter in the Lucene Sandbox.
Here's a test case I wrote for it for Lucene in Action (the test case
is in the sandbox also):
public void testAND() throws Exception {
ChainedFilter chain = new ChainedFilter(
new Filter[] {dateFilter, bobFilter}, ChainedFilter.AND);
Hits hits = searcher.search(query, chain);
assertEquals("AND matches just bob", MAX / 2, hits.length());
assertEquals("bob", hits.doc(0).get("owner"));
}
(you'll need to see the setUp method to make sense of the asserts,
though).
<http://cvs.apache.org/viewcvs.cgi/jakarta-lucene-sandbox/
contributions/miscellaneous/src/java/org/apache/lucene/misc/
ChainedFilter.java?view=markup>
The test cases are here:
<http://cvs.apache.org/viewcvs.cgi/jakarta-lucene-sandbox/
contributions/miscellaneous/src/test/org/apache/lucene/misc/
ChainedFilterTest.java?view=markup>
It's obviously a bit more complicated than a simple AND, though, but
does that simple case as well.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]