lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: Rewrite for RegexpQuery
Date Mon, 11 Mar 2013 13:13:26 GMT
> Set<Term> terms = new HashSet<>();
> MultiTermQuery query = new RegexpQuery(new Term("text", query));
> query.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_RE
> WRITE);
> BooleanQuery bq = (BooleanQuery) query.rewrite(reader);
> bq.extractTerms(terms);
> 
> 
> Regarding the application of IndexSearcher.rewrite(Query) instead: I don't
> see a way to set the rewrite method there because the Query's rewrite
> method does not seem to apply to IndexSearcher.rewrite().

Replace:
> BooleanQuery bq = (BooleanQuery) query.rewrite(reader);

With:
> BooleanQuery bq = (BooleanQuery) indexSearcher.rewrite(query);

Otherwise you have to create a while-loop that rewrites the return value again until rewrite()
returns itself.

Uwe


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