lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kelvin Tan" <kel...@relevanz.com>
Subject Re: Chainable Filter contribution
Date Thu, 28 Mar 2002 01:57:50 GMT
Dan,

Totally my bad. I had since changed it but hadn't posted it to the list coz
I didn't think anyone found it useful.

Here's the correct version. I haven't really documented since it's pretty
straightforward. Just holler if you need any help.

Regards,
Kelvin
----- Original Message -----
From: "Armbrust, Daniel C." <Armbrust.Daniel@mayo.edu>
To: <kelvin@relevanz.com>
Sent: Thursday, March 28, 2002 5:17 AM
Subject: Chainable Filter contribution


> I found this in the mailing list, and I do need something like this, as I
> need to apply more than one filter at a time.  I'm fairly new to lucene,
> however, and my knowledge of BitSets is very limited.
>
> My question, if you would be so kind as to donate a minute of time to me,
is
> how does this combine the filters?  From my nieve look through it, it
seems
> that all filter results would get discarded except for the last filter
that
> was applied.
>
>
> Thanks,
>
> Dan
>
>
>
> import org.apache.lucene.index.IndexReader;
> import org.apache.lucene.search.Filter;
>
> import java.io.IOException;
> import java.util.BitSet;
>
> /**
>  * <p>
>  * A ChainableFilter allows multiple filters to be chained
>  * such that the result is the intersection of all the
>  * filters.
>  * </p>
>  * <p>
>  * Order in which filters are called depends on
>  * the position of the filter in the chain. It's probably
>  * more efficient to place the most restrictive filters
>  * /least computationally-intensive filters first.
>  * </p>
>  *
>  * @author <a href="mailto:kelvin@relevanz.com">Kelvin Tan</a>
>  */
> public class ChainableFilter extends Filter
> {
>     /** The filter chain */
>     private Filter[] chain = null;
>
>     /**
>      * Creates a new ChainableFilter.
>      *
>      * @param chain The chain of filters.
>      */
>     public ChainableFilter(Filter[] chain)
>     {
>         this.chain = chain;
>     }
>
>     public BitSet bits(IndexReader reader) throws IOException
>     {
>         BitSet result = null;
>         for (int i = 0; i < chain.length; i++)
>         {
>             result = chain[i].bits(reader);
>         }
>         return result;
>     }
> }
>
>

Mime
View raw message