Class CustomScoreQuery

  • All Implemented Interfaces:
    Cloneable

    @Deprecated
    public class CustomScoreQuery
    extends Query
    implements Cloneable
    Deprecated.
    Query that sets document score as a programmatic function of several (sub) scores:
    1. the score of its subQuery (any query)
    2. (optional) the score of its FunctionQuery (or queries).
    Subclasses can modify the computation by overriding getCustomScoreProvider(org.apache.lucene.index.LeafReaderContext).
    WARNING: This API is experimental and might change in incompatible ways in the next release.
    Clients should instead use FunctionScoreQuery. For simple multiplicative boosts, use FunctionScoreQuery.boostByValue(Query, DoubleValuesSource). For more complex custom scores, use the lucene-expressions library
       SimpleBindings bindings = new SimpleBindings();
       bindings.add("score", DoubleValuesSource.SCORES);
       bindings.add("boost1", DoubleValuesSource.fromIntField("myboostfield"));
       bindings.add("boost2", DoubleValuesSource.fromIntField("myotherboostfield"));
       Expression expr = JavascriptCompiler.compile("score * (boost1 + ln(boost2))");
       FunctionScoreQuery q = new FunctionScoreQuery(inputQuery, expr.getDoubleValuesSource(bindings));
     
    • Constructor Detail

      • CustomScoreQuery

        public CustomScoreQuery​(Query subQuery)
        Deprecated.
        Create a CustomScoreQuery over input subQuery.
        Parameters:
        subQuery - the sub query whose scored is being customized. Must not be null.
      • CustomScoreQuery

        public CustomScoreQuery​(Query subQuery,
                                FunctionQuery scoringQuery)
        Deprecated.
        Create a CustomScoreQuery over input subQuery and a FunctionQuery.
        Parameters:
        subQuery - the sub query whose score is being customized. Must not be null.
        scoringQuery - a value source query whose scores are used in the custom score computation. This parameter is optional - it can be null.
      • CustomScoreQuery

        public CustomScoreQuery​(Query subQuery,
                                FunctionQuery... scoringQueries)
        Deprecated.
        Create a CustomScoreQuery over input subQuery and a FunctionQuery.
        Parameters:
        subQuery - the sub query whose score is being customized. Must not be null.
        scoringQueries - value source queries whose scores are used in the custom score computation. This parameter is optional - it can be null or even an empty array.