No prob....was a bit hasty though:
replace
= new BitSet();
with
= new BitSet(reader.maxDocs());
Beard, Brian wrote:
> Mark,
>
> Thanks so much.
>
> -----Original Message-----
> From: Mark Miller [mailto:markrmiller gmail.com]
> Sent: Friday, October 12, 2007 1:54 PM
> To: java-user lucene.apache.org
> Subject: Re: Wildcard & filters
>
> Something along these lines:
>
> 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;
> }
> }
>
> - Mark
>
> Beard, Brian wrote:
>
>> I'm trying to over-ride
QueryParser.getWildcardQuery to use filtering.
>>
>> I'm missing something, because the following still
gets the
>> maxBooleanClauses limit.
>>
>> I guess the terms are still expanded even though
the query is wrapped
>>
> in
>
>> a filter. How do I avoid the term expansion
altogether? Is there a
>> built-in way to do this?
>>
>> protected Query getWildcardQuery(String field,
String termStr)
>> throws ParseException {
>>
>> Query wildcardQuery = new WildcardQuery(new
Term(field,
>> termStr));
>>
>> QueryWrapperFilter queryWrapperFilter = new
>> QueryWrapperFilter(wildcardQuery);
>>
>> ConstantScoreQuery constantScoreQuery = new
>> ConstantScoreQuery(queryWrapperFilter);
>>
>> return constantScoreQuery;
>>
>> }
>>
>>
>>
------------------------------------------------------------
---------
>> To unsubscribe, e-mail: java-user-unsubscribe lucene.apache.org
>> For additional commands, e-mail: java-user-help lucene.apache.org
>>
>>
>>
>>
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: java-user-unsubscribe lucene.apache.org
> For additional commands, e-mail: java-user-help lucene.apache.org
>
>
>
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: java-user-unsubscribe lucene.apache.org
> For additional commands, e-mail: java-user-help lucene.apache.org
>
>
>
------------------------------------------------------------
---------
To unsubscribe, e-mail: java-user-unsubscribe lucene.apache.org
For additional commands, e-mail: java-user-help lucene.apache.org
|