Search in sources :

Example 1 with LeafScoreFunction

use of org.opensearch.common.lucene.search.function.LeafScoreFunction in project OpenSearch by opensearch-project.

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.opensearch.common.lucene.search.function.WeightFactorFunction) LeafReaderContext(org.apache.lucene.index.LeafReaderContext) IOException(java.io.IOException) LeafScoreFunction(org.opensearch.common.lucene.search.function.LeafScoreFunction) LeafScoreFunction(org.opensearch.common.lucene.search.function.LeafScoreFunction) FilterScoreFunction(org.opensearch.common.lucene.search.function.FunctionScoreQuery.FilterScoreFunction) RandomScoreFunction(org.opensearch.common.lucene.search.function.RandomScoreFunction) ScoreFunction(org.opensearch.common.lucene.search.function.ScoreFunction)

Aggregations

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