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

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

A Query that matches documents containing a particular sequence of terms. A PhraseQuery is built by QueryParser for input like "new york". More...

`#include <PhraseQuery.h>`

Inheritance diagram for Lucene::PhraseQuery:

## Public Member Functions

| PhraseQuery ()
| Constructs an empty phrase query. More...
virtual | ~PhraseQuery ()
virtual String | getClassName ()
boost::shared_ptr< PhraseQuery > | shared_from_this ()
void | setSlop (int32_t slop)
| Sets the number of other words permitted between words in query phrase. If zero, then this is an exact phrase search. For larger values this works like a WITHIN or NEAR operator. More...
int32_t | getSlop ()
| Returns the slop. More...
void | add (const TermPtr &term)
| Adds a term to the end of the query phrase. The relative position of the term is the one immediately after the last term added. More...
void | add (const TermPtr &term, int32_t position)
| Adds a term to the end of the query phrase. The relative position of the term within the phrase is specified explicitly. This allows eg. phrases with more than one term at the same position or phrases with gaps (eg. in connection with stopwords). More...
Collection< TermPtr > | getTerms ()
| Returns the set of terms in this phrase. More...
Collection< int32_t > | getPositions ()
| Returns the relative positions of terms in this phrase. 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 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 String | toString (const String &field)
| Prints a user-readable version of this query. More...
virtual bool | equals (const LuceneObjectPtr &other)
| Return whether two objects are equal. More...
virtual int32_t | hashCode ()
| Return hash code for this object. More...
virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr())
| Returns a clone of this query. More...
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. 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 ()
| Prints a query to a string. 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 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...
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 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. More...

## Protected Attributes

String | field
Collection< TermPtr > | terms
Collection< int32_t > | positions
int32_t | maxPosition
int32_t | slop
Protected Attributes inherited from Lucene::Query
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

A Query that matches documents containing a particular sequence of terms. A PhraseQuery is built by QueryParser for input like "new york".

This query may be combined with other terms or queries with a BooleanQuery.

## Constructor & Destructor Documentation

## ◆ PhraseQuery()

Lucene::PhraseQuery::PhraseQuery | ( |  | ) |

Constructs an empty phrase query.

## ◆ ~PhraseQuery()

virtual Lucene::PhraseQuery::~PhraseQuery | ( |  | ) |

virtual

## Member Function Documentation

## ◆ _getClassName()

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

inline static

## ◆ add() [1/2]

void Lucene::PhraseQuery::add | ( | const TermPtr & | term | ) |

Adds a term to the end of the query phrase. The relative position of the term is the one immediately after the last term added.

## ◆ add() [2/2]

void Lucene::PhraseQuery::add | ( | const TermPtr & | term,
|  | int32_t | position
| ) |  |

Adds a term to the end of the query phrase. The relative position of the term within the phrase is specified explicitly. This allows eg. phrases with more than one term at the same position or phrases with gaps (eg. in connection with stopwords).

## ◆ clone()

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

virtual

Returns a clone of this query.

Reimplemented from Lucene::Query.

## ◆ createWeight()

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

virtual

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

Reimplemented from Lucene::Query.

## ◆ equals()

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

virtual

Return whether two objects are equal.

Reimplemented from Lucene::Query.

## ◆ extractTerms()

virtual void Lucene::PhraseQuery::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 from Lucene::Query.

## ◆ getClassName()

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

inline virtual

Reimplemented from Lucene::Query.

## ◆ getPositions()

Collection<int32_t> Lucene::PhraseQuery::getPositions | ( |  | ) |

Returns the relative positions of terms in this phrase.

## ◆ getSlop()

int32_t Lucene::PhraseQuery::getSlop | ( |  | ) |

Returns the slop.

See also
  setSlop()

## ◆ getTerms()

Collection<TermPtr> Lucene::PhraseQuery::getTerms | ( |  | ) |

Returns the set of terms in this phrase.

## ◆ hashCode()

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

virtual

Return hash code for this object.

Reimplemented from Lucene::Query.

## ◆ setSlop()

void Lucene::PhraseQuery::setSlop | ( | int32_t | slop | ) |

Sets the number of other words permitted between words in query phrase. If zero, then this is an exact phrase search. For larger values this works like a WITHIN or NEAR operator.

The slop is in fact an edit-distance, where the units correspond to moves of terms in the query phrase out of position. For example, to switch the order of two words requires two moves (the first move places the words atop one another), so to permit re-orderings of phrases, the slop must be at least two.

More exact matches are scored higher than sloppier matches, thus search results are sorted by exactness.

The slop is zero by default, requiring exact matches.

## ◆ shared_from_this()

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

inline

## ◆ toString()

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

virtual

Prints a user-readable version of this query.

Reimplemented from Lucene::Query.

## Field Documentation

## ◆ field

String Lucene::PhraseQuery::field

protected

## ◆ maxPosition

int32_t Lucene::PhraseQuery::maxPosition

protected

## ◆ positions

Collection<int32_t> Lucene::PhraseQuery::positions

protected

## ◆ slop

int32_t Lucene::PhraseQuery::slop

protected

## ◆ terms

Collection<TermPtr> Lucene::PhraseQuery::terms

protected

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

- PhraseQuery.h

clucene.sourceforge.net