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

Public Member Functions | Static Public Member Functions | Protected Attributes
Lucene::Query Class Reference

The abstract base class for queries. More...

`#include <Query.h>`

Inheritance diagram for Lucene::Query:

## Public Member Functions

| Query ()
virtual | ~Query ()
virtual String | getClassName ()
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. More...
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. More...
virtual String | toString (const String &field)
| Prints a query to a string, with field assumed to be the default field and omitted. More...
virtual String | toString ()
| Prints a query to a string. More...
virtual WeightPtr | createWeight (const SearcherPtr &searcher)
| Constructs an appropriate Weight implementation for this query. Only implemented by primitive queries, which re-write to themselves. More...
virtual WeightPtr | weight (const SearcherPtr &searcher)
| Constructs and initializes a Weight for a top-level query. More...
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. More...
virtual QueryPtr | combine (Collection< QueryPtr > queries)
| Called when re-writing queries under MultiSearcher. More...
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. More...
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. More...
virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr())
| Returns a clone of this query. More...
virtual int32_t | hashCode ()
| Return hash code for this object. More...
virtual bool | equals (const LuceneObjectPtr &other)
| Return whether two objects are equal. More...
String | boostString ()
| Return given boost value as a string. More...
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. More...
virtual int32_t | compareTo (const LuceneObjectPtr &other)
| Compare two objects. More...
Public Member Functions inherited from Lucene::LuceneSync
virtual | ~LuceneSync ()
virtual SynchronizePtr | getSync ()
| Return this object synchronize lock. More...
virtual LuceneSignalPtr | getSignal ()
| Return this object signal. More...
virtual void | lock (int32_t timeout=0)
| Lock this object using an optional timeout. More...
virtual void | unlock ()
| Unlock this object. More...
virtual bool | holdsLock ()
| Returns true if this object is currently locked by current thread. More...
virtual void | wait (int32_t timeout=0)
| Wait for signal using an optional timeout. More...
virtual void | notifyAll ()
| Notify all threads waiting for signal. More...

## Static Public Member Functions

static String | _getClassName ()
static QueryPtr | mergeBooleanQueries (Collection< BooleanQueryPtr > queries)
| Merges the clauses of a set of BooleanQuery's into a single BooleanQuery. More...

## Protected Attributes

double | boost
Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr | objectLock
LuceneSignalPtr | objectSignal

## Additional Inherited Members

Protected Member Functions inherited from Lucene::LuceneObject
| LuceneObject ()

## Detailed Description

The abstract base class for queries.

Instantiable subclasses are:

TermQuery MultiTermQuery BooleanQuery WildcardQuery PhraseQuery PrefixQuery MultiPhraseQuery FuzzyQuery TermRangeQuery NumericRangeQuery org.apache.lucene.search.spans.SpanQuery

A parser for queries is contained in: QueryParser

## Constructor & Destructor Documentation

## ◆ Query()

Lucene::Query::Query | ( |  | ) |

## ◆ ~Query()

virtual Lucene::Query::~Query | ( |  | ) |

virtual

## Member Function Documentation

## ◆ _getClassName()

static String Lucene::Query::_getClassName | ( |  | ) |

inline static

## ◆ boostString()

String Lucene::Query::boostString | ( |  | ) |

Return given boost value as a string.

## ◆ clone()

virtual LuceneObjectPtr Lucene::Query::clone | ( | const LuceneObjectPtr & | other = `LuceneObjectPtr()` | ) |

virtual

Returns a clone of this query.

Reimplemented from Lucene::LuceneObject.

Reimplemented in Lucene::NumericRangeQuery, Lucene::MultiTermQuery, Lucene::BooleanQuery, Lucene::FieldMaskingSpanQuery, Lucene::TermRangeQuery, Lucene::DisjunctionMaxQuery, Lucene::PhraseQuery, Lucene::MultiPhraseQuery, Lucene::FuzzyQuery, Lucene::FilteredQuery, Lucene::CustomScoreQuery, Lucene::SpanNearQuery, Lucene::ConstantScoreQuery, Lucene::ValueSourceQuery, Lucene::WildcardQuery, Lucene::PayloadNearQuery, Lucene::TermQuery, Lucene::PrefixQuery, Lucene::SpanFirstQuery, Lucene::SpanNotQuery, Lucene::SpanTermQuery, Lucene::MatchAllDocsQuery, Lucene::PayloadTermQuery, and Lucene::SpanOrQuery.

## ◆ combine()

virtual QueryPtr Lucene::Query::combine | ( | Collection< QueryPtr > | queries | ) |

virtual

Called when re-writing queries under MultiSearcher.

Create a single query suitable for use by all subsearchers (in 1-1 correspondence with queries). This is an optimization of the OR of all queries. We handle the common optimization cases of equal queries and overlapping clauses of boolean OR queries (as generated by MultiTermQuery.rewrite()). Be careful overriding this method as queries[0] determines which method will be called and is not necessarily of the same type as the other queries.

## ◆ createWeight()

virtual WeightPtr Lucene::Query::createWeight | ( | const SearcherPtr & | searcher | ) |

virtual

Constructs an appropriate Weight implementation for this query. Only implemented by primitive queries, which re-write to themselves.

Reimplemented in Lucene::CustomScoreQuery, Lucene::BooleanQuery, Lucene::FieldMaskingSpanQuery, Lucene::DisjunctionMaxQuery, Lucene::PhraseQuery, Lucene::MultiPhraseQuery, Lucene::FilteredQuery, Lucene::PayloadNearQuery, Lucene::ValueSourceQuery, Lucene::ConstantScoreQuery, Lucene::TermQuery, Lucene::PayloadTermQuery, Lucene::MatchAllDocsQuery, and Lucene::SpanQuery.

## ◆ equals()

virtual bool Lucene::Query::equals | ( | const LuceneObjectPtr & | other | ) |

virtual

Return whether two objects are equal.

Reimplemented from Lucene::LuceneObject.

Reimplemented in Lucene::NumericRangeQuery, Lucene::MultiTermQuery, Lucene::BooleanQuery, Lucene::DisjunctionMaxQuery, Lucene::TermRangeQuery, Lucene::FieldMaskingSpanQuery, Lucene::PhraseQuery, Lucene::FuzzyQuery, Lucene::MultiPhraseQuery, Lucene::CustomScoreQuery, Lucene::FilteredQuery, Lucene::SpanNearQuery, Lucene::WildcardQuery, Lucene::PayloadNearQuery, Lucene::SpanFirstQuery, Lucene::SpanNotQuery, Lucene::ConstantScoreQuery, Lucene::ValueSourceQuery, Lucene::PrefixQuery, Lucene::TermQuery, Lucene::SpanOrQuery, Lucene::PayloadTermQuery, Lucene::SpanTermQuery, and Lucene::MatchAllDocsQuery.

## ◆ extractTerms()

virtual void Lucene::Query::extractTerms | ( | SetTerm | terms | ) |

virtual

Adds all terms occurring in this query to the terms set. Only works if this query is in its rewritten form.

Reimplemented in Lucene::BooleanQuery, Lucene::DisjunctionMaxQuery, Lucene::FieldMaskingSpanQuery, Lucene::PhraseQuery, Lucene::MultiPhraseQuery, Lucene::CustomScoreQuery, Lucene::FilteredQuery, Lucene::SpanNearQuery, Lucene::SpanFirstQuery, Lucene::ValueSourceQuery, Lucene::SpanNotQuery, Lucene::ConstantScoreQuery, Lucene::TermQuery, Lucene::SpanOrQuery, Lucene::SpanTermQuery, and Lucene::MatchAllDocsQuery.

## ◆ getBoost()

virtual double Lucene::Query::getBoost | ( |  | ) |

virtual

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.

## ◆ getClassName()

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

inline virtual

Reimplemented in Lucene::NumericRangeQuery, Lucene::FieldScoreQuery, Lucene::FieldMaskingSpanQuery, Lucene::TermRangeQuery, Lucene::DisjunctionMaxQuery, Lucene::CustomScoreQuery, Lucene::MultiTermQuery, Lucene::FuzzyQuery, Lucene::PayloadNearQuery, Lucene::BooleanQuery, Lucene::FilteredQuery, Lucene::ValueSourceQuery, Lucene::PayloadTermQuery, Lucene::WildcardQuery, Lucene::PrefixQuery, Lucene::PhraseQuery, Lucene::SpanNearQuery, Lucene::ConstantScoreQuery, Lucene::MultiPhraseQuery, Lucene::TermQuery, Lucene::MatchAllDocsQuery, Lucene::SpanFirstQuery, Lucene::SpanNotQuery, Lucene::SpanOrQuery, Lucene::SpanTermQuery, and Lucene::SpanQuery.

## ◆ getSimilarity()

virtual SimilarityPtr Lucene::Query::getSimilarity | ( | const SearcherPtr & | searcher | ) |

virtual

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.

Reimplemented in Lucene::FieldMaskingSpanQuery, and Lucene::BooleanQuery.

## ◆ hashCode()

virtual int32_t Lucene::Query::hashCode | ( |  | ) |

virtual

Return hash code for this object.

Reimplemented from Lucene::LuceneObject.

Reimplemented in Lucene::NumericRangeQuery, Lucene::MultiTermQuery, Lucene::BooleanQuery, Lucene::DisjunctionMaxQuery, Lucene::TermRangeQuery, Lucene::FieldMaskingSpanQuery, Lucene::PhraseQuery, Lucene::MultiPhraseQuery, Lucene::FuzzyQuery, Lucene::CustomScoreQuery, Lucene::FilteredQuery, Lucene::SpanNearQuery, Lucene::PayloadNearQuery, Lucene::SpanFirstQuery, Lucene::WildcardQuery, Lucene::SpanNotQuery, Lucene::ConstantScoreQuery, Lucene::ValueSourceQuery, Lucene::TermQuery, Lucene::PrefixQuery, Lucene::SpanOrQuery, Lucene::PayloadTermQuery, Lucene::SpanTermQuery, and Lucene::MatchAllDocsQuery.

## ◆ mergeBooleanQueries()

static QueryPtr Lucene::Query::mergeBooleanQueries | ( | Collection< BooleanQueryPtr > | queries | ) |

static

Merges the clauses of a set of BooleanQuery's into a single BooleanQuery.

A utility for use by combine(Query[]) implementations.

## ◆ rewrite()

virtual QueryPtr Lucene::Query::rewrite | ( | const IndexReaderPtr & | reader | ) |

virtual

Called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.

Reimplemented in Lucene::MultiTermQuery, Lucene::BooleanQuery, Lucene::DisjunctionMaxQuery, Lucene::FieldMaskingSpanQuery, Lucene::FuzzyQuery, Lucene::MultiPhraseQuery, Lucene::CustomScoreQuery, Lucene::SpanNearQuery, Lucene::FilteredQuery, Lucene::SpanFirstQuery, Lucene::SpanNotQuery, Lucene::WildcardQuery, Lucene::ValueSourceQuery, Lucene::SpanOrQuery, and Lucene::ConstantScoreQuery.

## ◆ setBoost()

virtual void Lucene::Query::setBoost | ( | double | b | ) |

virtual

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.

## ◆ shared_from_this()

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

inline

## ◆ toString() [1/2]

virtual String Lucene::Query::toString | ( |  | ) |

virtual

Prints a query to a string.

Reimplemented from Lucene::LuceneObject.

## ◆ toString() [2/2]

virtual String Lucene::Query::toString | ( | const String & | field | ) |

virtual

Prints a query to a string, with field assumed to be the default field and omitted.

The representation used is one that is supposed to be readable by QueryParser. However, there are the following limitations:

If the query was created by the parser, the printed representation may not be exactly what was parsed. For example, characters that need to be escaped will be represented without the required backslash.

Some of the more complicated queries (eg. span queries) don't have a representation that can be parsed by QueryParser.

Reimplemented in Lucene::NumericRangeQuery, Lucene::BooleanQuery, Lucene::DisjunctionMaxQuery, Lucene::TermRangeQuery, Lucene::FieldMaskingSpanQuery, Lucene::PhraseQuery, Lucene::FuzzyQuery, Lucene::MultiPhraseQuery, Lucene::CustomScoreQuery, Lucene::FilteredQuery, Lucene::SpanNearQuery, Lucene::PayloadNearQuery, Lucene::WildcardQuery, Lucene::ValueSourceQuery, Lucene::ConstantScoreQuery, Lucene::SpanFirstQuery, Lucene::SpanNotQuery, Lucene::TermQuery, Lucene::PrefixQuery, Lucene::SpanOrQuery, Lucene::SpanTermQuery, and Lucene::MatchAllDocsQuery.

## ◆ weight()

virtual WeightPtr Lucene::Query::weight | ( | const SearcherPtr & | searcher | ) |

virtual

Constructs and initializes a Weight for a top-level query.

## Field Documentation

## ◆ boost

double Lucene::Query::boost

protected

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

- Query.h

clucene.sourceforge.net