Search in sources :

Example 6 with WeightFactorFunction

use of org.opensearch.common.lucene.search.function.WeightFactorFunction 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

WeightFactorFunction (org.opensearch.common.lucene.search.function.WeightFactorFunction)6 FunctionScoreQuery (org.opensearch.common.lucene.search.function.FunctionScoreQuery)4 TopDocs (org.apache.lucene.search.TopDocs)3 Explanation (org.apache.lucene.search.Explanation)2 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)2 TermQuery (org.apache.lucene.search.TermQuery)2 FilterScoreFunction (org.opensearch.common.lucene.search.function.FunctionScoreQuery.FilterScoreFunction)2 IOException (java.io.IOException)1 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)1 Term (org.apache.lucene.index.Term)1 IndexSearcher (org.apache.lucene.search.IndexSearcher)1 MatchNoDocsQuery (org.apache.lucene.search.MatchNoDocsQuery)1 Query (org.apache.lucene.search.Query)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 CombineFunction (org.opensearch.common.lucene.search.function.CombineFunction)1 FieldValueFactorFunction (org.opensearch.common.lucene.search.function.FieldValueFactorFunction)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 MatchAllQueryBuilder (org.opensearch.index.query.MatchAllQueryBuilder)1