lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: Uable to extends TopTermsRewrite in Lucene 4.1
Date Thu, 04 Apr 2013 20:15:41 GMT
> Okay, think I have it now. Now have a working rewrite method for Fuzzy
> Queries
> 
>      public static class FuzzyTermRewrite<Q extends DisjunctionMaxQuery>
> extends TopTermsRewrite<Query> {
> 
>          public FuzzyTermRewrite(int size) {
>              super(size);
>          }
> 
>          @Override
>          protected int getMaxSize() {
>              return BooleanQuery.getMaxClauseCount();
>          }
> 
>          @Override
>          protected DisjunctionMaxQuery getTopLevelQuery() {
>              return new DisjunctionMaxQuery(0.1f);
>          }
> 
>          @Override
>          protected void addClause(Query topLevel, Term term, int docCount,
> float boost, TermContext states) {
>              final Query tq = new ConstantScoreQuery(new TermQuery(term,
> states));
>              tq.setBoost(boost);
>              ((DisjunctionMaxQuery)topLevel).add(tq);
>          }
>      }
> 
> and now writing a separate class for Prefix Queries so it does actually modify
> the idf


Hi,
looks OK, only the generics are wrong, must be:

public static class FuzzyTermRewrite extends TopTermsRewrite<DisjunctionMaxQuery> {

And then:

protected void addClause(DisjunctionMaxQuery topLevel, Term term, int docCount, float boost,
TermContext states) {

This cast is then obsolete: ((DisjunctionMaxQuery)topLevel).add(tq);

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