Search in sources :

Example 1 with LeafScoreFunction

use of org.elasticsearch.common.lucene.search.function.LeafScoreFunction in project elasticsearch by elastic.

the class FunctionScoreTests method testWeightFactorNeedsScore.

public void testWeightFactorNeedsScore() {
    for (boolean needsScore : new boolean[] { true, false }) {
        WeightFactorFunction function = new WeightFactorFunction(10.0f, new ScoreFunction(CombineFunction.REPLACE) {

            @Override
            public LeafScoreFunction getLeafScoreFunction(LeafReaderContext ctx) throws IOException {
                return null;
            }

            @Override
            public boolean needsScores() {
                return needsScore;
            }

            @Override
            protected boolean doEquals(ScoreFunction other) {
                return false;
            }

            @Override
            protected int doHashCode() {
                return 0;
            }
        });
        assertEquals(needsScore, function.needsScores());
    }
}
Also used : WeightFactorFunction(org.elasticsearch.common.lucene.search.function.WeightFactorFunction) LeafReaderContext(org.apache.lucene.index.LeafReaderContext) IOException(java.io.IOException) LeafScoreFunction(org.elasticsearch.common.lucene.search.function.LeafScoreFunction) ScoreFunction(org.elasticsearch.common.lucene.search.function.ScoreFunction) LeafScoreFunction(org.elasticsearch.common.lucene.search.function.LeafScoreFunction) RandomScoreFunction(org.elasticsearch.common.lucene.search.function.RandomScoreFunction)

Aggregations

IOException (java.io.IOException)1 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)1 LeafScoreFunction (org.elasticsearch.common.lucene.search.function.LeafScoreFunction)1 RandomScoreFunction (org.elasticsearch.common.lucene.search.function.RandomScoreFunction)1 ScoreFunction (org.elasticsearch.common.lucene.search.function.ScoreFunction)1 WeightFactorFunction (org.elasticsearch.common.lucene.search.function.WeightFactorFunction)1