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


 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
Lucene::MultiPhraseQuery Class Reference

MultiPhraseQuery is a generalized version of PhraseQuery, with an added method add(Term[]). To use this class, to search for the phrase "Microsoft app*" first use add(Term) on the term "Microsoft", then find all terms that have "app" as prefix using IndexReader.terms(Term), and use MultiPhraseQuery.add(Term[] terms) to add them to the query. More...

#include <MultiPhraseQuery.h>

+ Inheritance diagram for Lucene::MultiPhraseQuery:

Public Member Functions

 MultiPhraseQuery ()
 
virtual ~MultiPhraseQuery ()
 
virtual String getClassName ()
 
boost::shared_ptr
< MultiPhraseQuery
shared_from_this ()
 
void setSlop (int32_t s)
 Sets the phrase slop for this query. More...
 
int32_t getSlop ()
 Gets the phrase slop for this query. More...
 
void add (TermPtr term)
 Add a single term at the next position in the phrase. More...
 
void add (Collection< TermPtr > terms)
 Add multiple terms at the next position in the phrase. Any of the terms may match. More...
 
void add (Collection< TermPtr > terms, int32_t position)
 Allows to specify the relative position of terms within the phrase. More...
 
Collection< Collection< TermPtr > > getTermArrays ()
 Returns a List of the terms in the multiphrase. Do not modify the List or its contents. More...
 
Collection< int32_t > getPositions ()
 Returns the relative positions of terms in this phrase. 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 QueryPtr rewrite (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 WeightPtr createWeight (SearcherPtr searcher)
 Constructs an appropriate Weight implementation for this query. Only implemented by primitive queries, which re-write to themselves. More...
 
virtual String toString (const String &field)
 Prints a user-readable version of this query. More...
 
virtual bool equals (LuceneObjectPtr other)
 Return whether two objects are equal. More...
 
virtual int32_t hashCode ()
 Return hash code for this object. More...
 
virtual LuceneObjectPtr clone (LuceneObjectPtr other=LuceneObjectPtr())
 Returns a clone of this query. More...
 
- Public Member Functions inherited from Lucene::Query
 Query ()
 
virtual ~Query ()
 
boost::shared_ptr< Queryshared_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 (SearcherPtr searcher)
 Constructs and initializes a Weight for a top-level query. More...
 
virtual QueryPtr combine (Collection< QueryPtr > queries)
 Called when re-writing queries under MultiSearcher. More...
 
virtual SimilarityPtr getSimilarity (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 (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 Member Functions

int32_t termArraysHashCode ()
 
bool termArraysEquals (Collection< Collection< TermPtr > > first, Collection< Collection< TermPtr > > second)
 

Protected Attributes

String field
 
Collection< Collection< TermPtr > > termArrays
 
Collection< int32_t > positions
 
int32_t slop
 
- Protected Attributes inherited from Lucene::Query
double boost
 

Detailed Description

MultiPhraseQuery is a generalized version of PhraseQuery, with an added method add(Term[]). To use this class, to search for the phrase "Microsoft app*" first use add(Term) on the term "Microsoft", then find all terms that have "app" as prefix using IndexReader.terms(Term), and use MultiPhraseQuery.add(Term[] terms) to add them to the query.

Constructor & Destructor Documentation

Lucene::MultiPhraseQuery::MultiPhraseQuery ( )
virtual Lucene::MultiPhraseQuery::~MultiPhraseQuery ( )
virtual

Member Function Documentation

static String Lucene::MultiPhraseQuery::_getClassName ( )
inlinestatic
void Lucene::MultiPhraseQuery::add ( TermPtr  term)

Add a single term at the next position in the phrase.

See Also
PhraseQuery::add(Term)
void Lucene::MultiPhraseQuery::add ( Collection< TermPtr terms)

Add multiple terms at the next position in the phrase. Any of the terms may match.

See Also
PhraseQuery::add(Term)
void Lucene::MultiPhraseQuery::add ( Collection< TermPtr terms,
int32_t  position 
)

Allows to specify the relative position of terms within the phrase.

See Also
PhraseQuery::add(Term, int)
virtual LuceneObjectPtr Lucene::MultiPhraseQuery::clone ( LuceneObjectPtr  other = LuceneObjectPtr())
virtual

Returns a clone of this query.

Reimplemented from Lucene::Query.

virtual WeightPtr Lucene::MultiPhraseQuery::createWeight ( 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.

virtual bool Lucene::MultiPhraseQuery::equals ( LuceneObjectPtr  other)
virtual

Return whether two objects are equal.

Reimplemented from Lucene::Query.

virtual void Lucene::MultiPhraseQuery::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.

virtual String Lucene::MultiPhraseQuery::getClassName ( )
inlinevirtual

Reimplemented from Lucene::Query.

Collection<int32_t> Lucene::MultiPhraseQuery::getPositions ( )

Returns the relative positions of terms in this phrase.

int32_t Lucene::MultiPhraseQuery::getSlop ( )

Gets the phrase slop for this query.

See Also
PhraseQuery::getSlop()
Collection< Collection<TermPtr> > Lucene::MultiPhraseQuery::getTermArrays ( )

Returns a List of the terms in the multiphrase. Do not modify the List or its contents.

virtual int32_t Lucene::MultiPhraseQuery::hashCode ( )
virtual

Return hash code for this object.

Reimplemented from Lucene::Query.

virtual QueryPtr Lucene::MultiPhraseQuery::rewrite ( 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 from Lucene::Query.

void Lucene::MultiPhraseQuery::setSlop ( int32_t  s)

Sets the phrase slop for this query.

See Also
PhraseQuery::setSlop(int32_t)
boost::shared_ptr< MultiPhraseQuery > Lucene::MultiPhraseQuery::shared_from_this ( )
inline
bool Lucene::MultiPhraseQuery::termArraysEquals ( Collection< Collection< TermPtr > >  first,
Collection< Collection< TermPtr > >  second 
)
protected
int32_t Lucene::MultiPhraseQuery::termArraysHashCode ( )
protected
virtual String Lucene::MultiPhraseQuery::toString ( const String &  field)
virtual

Prints a user-readable version of this query.

Reimplemented from Lucene::Query.

Field Documentation

String Lucene::MultiPhraseQuery::field
protected
Collection<int32_t> Lucene::MultiPhraseQuery::positions
protected
int32_t Lucene::MultiPhraseQuery::slop
protected
Collection< Collection<TermPtr> > Lucene::MultiPhraseQuery::termArrays
protected

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

clucene.sourceforge.net