Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.queries
Class CustomScoreQuery

    java.lang.Object
      org.apache.lucene.search.Query
          org.apache.lucene.queries.CustomScoreQuery

All Implemented Interfaces:
  Cloneable

    public class CustomScoreQuery

extends Query

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.AtomicReaderContext)`.

WARNING: This API is experimental and might change in incompatible ways in the next release.

Constructor Summary
`CustomScoreQuery(Query subQuery)` Create a CustomScoreQuery over input subQuery.
`CustomScoreQuery(Query subQuery, Query... scoringQueries)` Create a CustomScoreQuery over input subQuery and a `FunctionQuery`.
`CustomScoreQuery(Query subQuery, Query scoringQuery)` Create a CustomScoreQuery over input subQuery and a `FunctionQuery`.

Method Summary
`CustomScoreQuery` | `clone()`
`Weight` | `createWeight(IndexSearcher searcher)`
`boolean` | `equals(Object o)` Returns true if `o` is equal to this.
`void` | `extractTerms(Set<Term> terms)`
`protected CustomScoreProvider` | `getCustomScoreProvider(AtomicReaderContext context)` Returns a `CustomScoreProvider` that calculates the custom scores for the given `IndexReader`.
`int` | `hashCode()` Returns a hash code value for this object.
`boolean` | `isStrict()` Checks if this is strict custom scoring.
`String` | `name()` A short name of this query, used in `toString(String)`.
`Query` | `rewrite(IndexReader reader)`
`void` | `setStrict(boolean strict)` Set the strict mode of this query.
`String` | `toString(String field)`

Methods inherited from class org.apache.lucene.search.Query
`getBoost, setBoost, toString`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### CustomScoreQuery

    public CustomScoreQuery(Query subQuery)

  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,
                            Query scoringQuery)

  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,
                            Query... scoringQueries)

  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.

Method Detail

### rewrite

    public Query rewrite(IndexReader reader)
                  throws IOException

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

### extractTerms

    public void extractTerms(Set<Term> terms)

  Overrides:
    `extractTerms` in class `Query`

### clone

    public CustomScoreQuery clone()

  Overrides:
    `clone` in class `Query`

### toString

    public String toString(String field)

  Specified by:
    `toString` in class `Query`

### equals

    public boolean equals(Object o)

  Returns true if `o` is equal to this.

  Overrides:
    `equals` in class `Query`

### hashCode

    public int hashCode()

  Returns a hash code value for this object.

  Overrides:
    `hashCode` in class `Query`

### getCustomScoreProvider

    protected CustomScoreProvider getCustomScoreProvider(AtomicReaderContext context)
                                                  throws IOException

  Returns a `CustomScoreProvider` that calculates the custom scores for the given `IndexReader`. The default implementation returns a default implementation as specified in the docs of `CustomScoreProvider`.

  Throws:
    `IOException`
  Since:
    2.9.2

### createWeight

    public Weight createWeight(IndexSearcher searcher)
                        throws IOException

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

### isStrict

    public boolean isStrict()

  Checks if this is strict custom scoring. In strict custom scoring, the `ValueSource` part does not participate in weight normalization. This may be useful when one wants full control over how scores are modified, and does not care about normalizing by the `ValueSource` part. One particular case where this is useful if for testing this query.

  Note: only has effect when the `ValueSource` part is not null.

### setStrict

    public void setStrict(boolean strict)

  Set the strict mode of this query.

  Parameters:
    `strict` - The strict mode to set.
  See Also:
    `isStrict()`

### name

    public String name()

  A short name of this query, used in `toString(String)`.

Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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