Home » lucene-3.0.1-src » org.apache » lucene » search » function » [javadoc | source]
org.apache.lucene.search.function
public class: FieldScoreQuery [javadoc | source]
java.lang.Object
   org.apache.lucene.search.Query
      org.apache.lucene.search.function.ValueSourceQuery
         org.apache.lucene.search.function.FieldScoreQuery

All Implemented Interfaces:
    Cloneable, Serializable

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:

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 constructing 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:

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.
Nested Class Summary:
public static class  FieldScoreQuery.Type  Type of score field, indicating how field values are interpreted/parsed.

The type selected at search search time should match the data stored in the field. Different types have different RAM requirements:

  • {@link #BYTE} consumes 1 * maxDocs bytes.
  • {@link #SHORT} consumes 2 * maxDocs bytes.
  • {@link #INT} consumes 4 * maxDocs bytes.
  • {@link #FLOAT} consumes 8 * maxDocs bytes.
 
Fields inherited from org.apache.lucene.search.function.ValueSourceQuery:
valSrc
Constructor:
 public FieldScoreQuery(String field,
    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.

Methods from org.apache.lucene.search.function.ValueSourceQuery:
createWeight,   equals,   extractTerms,   hashCode,   rewrite,   toString
Methods from org.apache.lucene.search.Query:
clone,   combine,   createWeight,   equals,   extractTerms,   getBoost,   getSimilarity,   hashCode,   mergeBooleanQueries,   rewrite,   setBoost,   toString,   toString,   weight
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait