lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Miller" <markrmil...@gmail.com>
Subject WildcardFilter
Date Tue, 05 Sep 2006 18:03:01 GMT
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;
    }

}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message