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

## org.apache.lucene.search.function
Class FieldScoreQuery

    java.lang.Object
      org.apache.lucene.search.Query
          org.apache.lucene.search.function.ValueSourceQuery
              org.apache.lucene.search.function.FieldScoreQuery

All Implemented Interfaces:
  Serializable, Cloneable

    public class FieldScoreQuery

extends ValueSourceQuery

A query that scores each document as the value of the numeric input field.

The query matches all documents, and scores each document according to the numeric value of that field.

It is assumed, and expected, that:

- The field used here is indexed, and has exactly one token in every scored document.
- Best if this field is un_tokenized.
- That token is parsable to the selected type.

Combining this query in a FunctionQuery allows much freedom in affecting document scores. Note, that with this freedom comes responsibility: it is more than likely that the default Lucene scoring is superior in quality to scoring modified as explained here. However, in some cases, and certainly for research experiments, this capability may turn useful.

When contructing this query, select the appropriate type. That type should match the data stored in the field. So in fact the "right" type should be selected before indexing. Type selection has effect on the RAM usage:

- `FieldScoreQuery.Type.BYTE` consumes 1 * maxDocs bytes.
- `FieldScoreQuery.Type.SHORT` consumes 2 * maxDocs bytes.
- `FieldScoreQuery.Type.INT` consumes 4 * maxDocs bytes.
- `FieldScoreQuery.Type.FLOAT` consumes 8 * maxDocs bytes.

Caching: Values for the numeric field are loaded once and cached in memory for further use with the same IndexReader. To take advantage of this, it is extremely important to reuse index-readers or index-searchers, otherwise, for instance if for each query a new index reader is opened, large penalties would be payd for loading the field values into memory over and over again!

WARNING: The status of the search.function package is experimental. The APIs introduced here might change in the future and will not be supported anymore in such a case.

See Also:
  Serialized Form

Nested Class Summary
`static class` | `FieldScoreQuery.Type` Type of score field, indicating how field values are interpreted/parsed.

Constructor Summary
`FieldScoreQuery(String field, FieldScoreQuery.Type type)` Create a FieldScoreQuery - a query that scores each document as the value of the numeric input field.

Method Summary

Methods inherited from class org.apache.lucene.search.function.ValueSourceQuery
`createWeight, equals, extractTerms, hashCode, rewrite, toString`

Methods inherited from class org.apache.lucene.search.Query
`clone, combine, getBoost, getSimilarity, mergeBooleanQueries, setBoost, toString, weight`

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

Constructor Detail

### FieldScoreQuery

    public FieldScoreQuery(String field,
                           FieldScoreQuery.Type type)

  Create a FieldScoreQuery - a query that scores each document as the value of the numeric input field.

  The `type` param tells how to parse the field string values into a numeric score value.

  Parameters:
    `field` - the numeric field to be used.
    `type` - the type of the field: either `FieldScoreQuery.Type.BYTE`, `FieldScoreQuery.Type.SHORT`, `FieldScoreQuery.Type.INT`, or `FieldScoreQuery.Type.FLOAT`.

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

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