Lucene++ - a full-featured, c++ search engine
API Documentation

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions
Lucene::FieldScoreQuery Class Reference

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

`#include <FieldScoreQuery.h>`

Inheritance diagram for Lucene::FieldScoreQuery:

## Public Types

enum | Type { BYTE , INT , DOUBLE }
| Type of score field, indicating how field values are interpreted/parsed. More...

## Public Member Functions

| FieldScoreQuery (const 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.
virtual | ~FieldScoreQuery ()
virtual String | getClassName ()
boost::shared_ptr< FieldScoreQuery > | shared_from_this ()
Public Member Functions inherited from Lucene::ValueSourceQuery
| ValueSourceQuery (const ValueSourcePtr &valSrc)
| Create a value source query.
virtual | ~ValueSourceQuery ()
boost::shared_ptr< ValueSourceQuery > | shared_from_this ()
virtual QueryPtr | rewrite (const IndexReaderPtr &reader)
| Called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.
virtual void | extractTerms (SetTerm terms)
| Adds all terms occurring in this query to the terms set. Only works if this query is in its `rewritten` form.
virtual WeightPtr | createWeight (const SearcherPtr &searcher)
| Constructs an appropriate Weight implementation for this query. Only implemented by primitive queries, which re-write to themselves.
virtual String | toString (const String &field)
| Prints a query to a string, with field assumed to be the default field and omitted.
virtual bool | equals (const LuceneObjectPtr &other)
| Return whether two objects are equal.
virtual int32_t | hashCode ()
| Return hash code for this object.
virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr())
| Returns a clone of this query.
virtual String | toString ()
| Prints a query to a string.
Public Member Functions inherited from Lucene::Query
| Query ()
virtual | ~Query ()
boost::shared_ptr< Query > | shared_from_this ()
virtual void | setBoost (double b)
| Sets the boost for this query clause to b. Documents matching this clause will (in addition to the normal weightings) have their score multiplied by b.
virtual double | getBoost ()
| Gets the boost for this clause. Documents matching this clause will (in addition to the normal weightings) have their score multiplied by b. The boost is 1.0 by default.
virtual WeightPtr | weight (const SearcherPtr &searcher)
| Constructs and initializes a Weight for a top-level query.
virtual QueryPtr | combine (Collection< QueryPtr > queries)
| Called when re-writing queries under MultiSearcher.
virtual SimilarityPtr | getSimilarity (const SearcherPtr &searcher)
| Returns the Similarity implementation to be used for this query. Subclasses may override this method to specify their own Similarity implementation, perhaps one that delegates through that of the Searcher. By default the Searcher's Similarity implementation is returned.
String | boostString ()
| Return given boost value as a string.
Public Member Functions inherited from Lucene::LuceneObject
virtual | ~LuceneObject ()
virtual void | initialize ()
| Called directly after instantiation to create objects that depend on this object being fully constructed.
virtual int32_t | compareTo (const LuceneObjectPtr &other)
| Compare two objects.
Public Member Functions inherited from Lucene::LuceneSync
virtual | ~LuceneSync ()
virtual SynchronizePtr | getSync ()
| Return this object synchronize lock.
virtual LuceneSignalPtr | getSignal ()
| Return this object signal.
virtual void | lock (int32_t timeout=0)
| Lock this object using an optional timeout.
virtual void | unlock ()
| Unlock this object.
virtual bool | holdsLock ()
| Returns true if this object is currently locked by current thread.
virtual void | wait (int32_t timeout=0)
| Wait for signal using an optional timeout.
virtual void | notifyAll ()
| Notify all threads waiting for signal.

## Static Public Member Functions

static String | _getClassName ()
static ValueSourcePtr | getValueSource (const String &field, Type type)
| Create the appropriate (cached) field value source.
Static Public Member Functions inherited from Lucene::ValueSourceQuery
static String | _getClassName ()
Static Public Member Functions inherited from Lucene::Query
static String | _getClassName ()
static QueryPtr | mergeBooleanQueries (Collection< BooleanQueryPtr > queries)
| Merges the clauses of a set of BooleanQuery's into a single BooleanQuery.

## Additional Inherited Members

Data Fields inherited from Lucene::ValueSourceQuery
ValueSourcePtr | valSrc
Protected Member Functions inherited from Lucene::LuceneObject
| LuceneObject ()
Protected Attributes inherited from Lucene::Query
double | boost
Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr | objectLock
LuceneSignalPtr | objectSignal

## Detailed Description

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

- Byte consumes 1 * maxDocs bytes.
- Int consumes 4 * maxDocs bytes.
- Double 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.

## Member Enumeration Documentation

## ◆ Type

enum Lucene::FieldScoreQuery::Type

Type of score field, indicating how field values are interpreted/parsed.

Enumerator
BYTE | Field values are interpreted as numeric byte values.
INT | Field values are interpreted as numeric integer values.
DOUBLE | Field values are interpreted as numeric double values.

## Constructor & Destructor Documentation

## ◆ FieldScoreQuery()

Lucene::FieldScoreQuery::FieldScoreQuery | ( | const 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.

Parameters

  field | the numeric field to be used.
  type | the type of the field.

Referenced by _getClassName().

## ◆ ~FieldScoreQuery()

virtual Lucene::FieldScoreQuery::~FieldScoreQuery | ( |  | ) |

virtual

## Member Function Documentation

## ◆ _getClassName()

String Lucene::FieldScoreQuery::_getClassName | ( |  | ) |

inline static

References FieldScoreQuery().

## ◆ getClassName()

virtual String Lucene::FieldScoreQuery::getClassName | ( |  | ) |

inline virtual

Reimplemented from Lucene::ValueSourceQuery.

## ◆ getValueSource()

ValueSourcePtr Lucene::FieldScoreQuery::getValueSource | ( | const String & | field,
|  | Type | type )

static

Create the appropriate (cached) field value source.

## ◆ shared_from_this()

boost::shared_ptr< FieldScoreQuery > Lucene::FieldScoreQuery::shared_from_this | ( |  | ) |

inline

The documentation for this class was generated from the following file:

- FieldScoreQuery.h

clucene.sourceforge.net