lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Huber <gregh3...@gmail.com>
Subject AnalyzingInfixSuggester Lucene 5.3.0
Date Mon, 24 Aug 2015 09:02:27 GMT
Hello,

I am extending AnalyzingInfixSuggester for use with my suggester where I
change the query to be a AND rather than an OR in the finishQuery(..)
method.

ie

/**
     * Subclass can override this to tweak the Query before searching.
     */
    protected Query finishQuery(Builder in, boolean allTermsRequired) {

        // Update contexts to be ANDs (MUST) rather than ORs (SHOULD)
        for (BooleanClause booleanClause : in.build().clauses()) {
            // Change the contexts to be MUST (will be the only
BooleanQuery and others will be TermQuery)
            if (booleanClause.getQuery() instanceof BooleanQuery) {
                BooleanQuery bq = (BooleanQuery) booleanClause.getQuery();
                for (BooleanClause bc : bq) {
                    bc.setOccur(BooleanClause.Occur.MUST);
                }
                // We are done
                break;
            }
        }

        return in.build();
    }

It says that BooleanClause.setOccur(..) is depreciated and will be *immutable
in 6.0*, how would I then be able to do this?

http://lucene.apache.org/core/5_3_0/core/org/apache/lucene/search/BooleanClause.html

Cheers Greg

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