lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eks dev <eks...@yahoo.co.uk>
Subject Re: WildcardFilter
Date Tue, 05 Sep 2006 18:30:42 GMT
I would rather use this 
BitSet bits = new BitSet(reader.maxDocs()); //Not sure of exact method, lucene is not on this
PC...
instead of = new BitSet(reader.maxDocs())


----- Original Message ----
From: Mark Miller <markrmiller@gmail.com>
To: java-user@lucene.apache.org
Sent: Tuesday, 5 September, 2006 8:03:01 PM
Subject: WildcardFilter

Could someone with some experience spot-check this WildcardFilter...it seems
to work fine in simple testing, but I'd like to know if there are any
glaring deficiencies. Have not had much to do with filters before.


public class WildcardFilter extends Filter {
    private Term term;

    public WildcardFilter(Term term) {
        this.term = term;
    }

    @Override
    public BitSet bits(IndexReader reader) throws IOException {
        BitSet bits = new BitSet();
        WildcardTermEnum enumerator = new WildcardTermEnum(reader, term);
        TermDocs termDocs = reader.termDocs();

        try {

          do {
            Term term = enumerator.term();
            if (term != null )
            {
              termDocs.seek(term);
              while (termDocs.next()) {
                bits.set(termDocs.doc());
              }
            } else {
              break;
            }
          } while (enumerator.next());
        } finally {
          termDocs.close();
          enumerator.close();
        }
      return bits;
    }

}




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


Mime
View raw message