lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Natarajan.T" <>
Subject RE: Filter !!!
Date Tue, 07 Dec 2004 11:09:22 GMT
Thanks your kind help Erik..........

-----Original Message-----
From: Erik Hatcher [] 
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 =, 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 =,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 =, 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,  


The test cases are here:


It's obviously a bit more complicated than a simple AND, though, but  
does that simple case as well.


To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message