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:

  • {@link Type#BYTE} consumes 1 * maxDocs bytes.
  • {@link Type#SHORT} consumes 2 * maxDocs bytes.
  • {@link Type#INT} consumes 4 * maxDocs bytes.
  • {@link 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 paid 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.

The FieldScoreQuery..::..Type type exposes the following members.

Methods

  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString (Overrides Object..::..ToString()()()().)

Fields

  NameDescription
Public fieldStatic memberBYTE
field values are interpreted as numeric byte values.
Public fieldStatic memberFLOAT
field values are interpreted as numeric float values.
Public fieldStatic memberINT
field values are interpreted as numeric int values.
Public fieldStatic memberSHORT
field values are interpreted as numeric short values.

See Also