org.apache.lucene.queries.function

## Class FunctionScoreQuery

- java.lang.Object
- - org.apache.lucene.search.Query
  - - org.apache.lucene.queries.function.FunctionScoreQuery

-     public final class FunctionScoreQuery
      extends Query

  A query that wraps another query, and uses a DoubleValuesSource to replace or modify the wrapped query's score If the DoubleValuesSource doesn't return a value for a particular document, then that document will be given a score of 0.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FunctionScoreQuery(Query in, DoubleValuesSource source)` Create a new FunctionScoreQuery

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static FunctionScoreQuery` | `boostByQuery(Query in, Query boostMatch, float boostValue)` Returns a FunctionScoreQuery where the scores of a wrapped query are multiplied by a boost factor if the document being scored also matches a separate boosting query.
    `static FunctionScoreQuery` | `boostByValue(Query in, DoubleValuesSource boost)` Returns a FunctionScoreQuery where the scores of a wrapped query are multiplied by the value of a DoubleValuesSource.
    `Weight` | `createWeight(IndexSearcher searcher, boolean needsScores, float boost)`
    `boolean` | `equals(Object o)`
    `Query` | `getWrappedQuery()`
    `int` | `hashCode()`
    `Query` | `rewrite(IndexReader reader)`
    `String` | `toString(String field)`

    - ### Methods inherited from class org.apache.lucene.search.Query

      `classHash, sameClassAs, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### FunctionScoreQuery

          public FunctionScoreQuery(Query in,
                                    DoubleValuesSource source)

      Create a new FunctionScoreQuery
      Parameters:
        `in` - the query to wrap
        `source` - a source of scores

  - ### Method Detail

    - #### getWrappedQuery

          public Query getWrappedQuery()

      Returns:
        the wrapped Query

    - #### boostByValue

          public static FunctionScoreQuery boostByValue(Query in,
                                                        DoubleValuesSource boost)

      Returns a FunctionScoreQuery where the scores of a wrapped query are multiplied by the value of a DoubleValuesSource. If the source has no value for a particular document, the score for that document is preserved as-is.
      Parameters:
        `in` - the query to boost
        `boost` - a `DoubleValuesSource` containing the boost values

    - #### boostByQuery

          public static FunctionScoreQuery boostByQuery(Query in,
                                                        Query boostMatch,
                                                        float boostValue)

      Returns a FunctionScoreQuery where the scores of a wrapped query are multiplied by a boost factor if the document being scored also matches a separate boosting query. Documents that do not match the boosting query have their scores preserved. This may be used to 'demote' documents that match the boosting query, by passing in a boostValue between 0 and 1.
      Parameters:
        `in` - the query to boost
        `boostMatch` - the boosting query
        `boostValue` - the amount to boost documents which match the boosting query

    - #### createWeight

          public Weight createWeight(IndexSearcher searcher,
                                     boolean needsScores,
                                     float boost)
                              throws IOException

      Overrides:
        `createWeight` in class `Query`
      Throws:
        `IOException`

    - #### rewrite

          public Query rewrite(IndexReader reader)
                        throws IOException

      Overrides:
        `rewrite` in class `Query`
      Throws:
        `IOException`

    - #### toString

          public String toString(String field)

      Specified by:
        `toString` in class `Query`

    - #### equals

          public boolean equals(Object o)

      Specified by:
        `equals` in class `Query`

    - #### hashCode

          public int hashCode()

      Specified by:
        `hashCode` in class `Query`

Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.