WildcardFilter

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

WildcardFilter

Mark Miller-3
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;
    }

}
Reply | Threaded
Open this post in threaded view
|

Re: WildcardFilter

Chris Hostetter-3

: 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.

It looks fine to me.


-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: WildcardFilter

eks dev
In reply to this post by Mark Miller-3
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 <[hidden email]>
To: [hidden email]
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: [hidden email]
For additional commands, e-mail: [hidden email]