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

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

A Query that matches documents matching boolean combinations of other queries, eg. TermQuerys, PhraseQuerys or other BooleanQuerys. More...

`#include <BooleanQuery.h>`

Inheritance diagram for Lucene::BooleanQuery:

## Public Member Functions

| BooleanQuery (bool disableCoord=false)
| Constructs an empty boolean query. More...
virtual | ~BooleanQuery ()
virtual String | getClassName ()
boost::shared_ptr< BooleanQuery > | shared_from_this ()
bool | isCoordDisabled ()
| Returns true if Similarity#coord(int32_t, int32_t) is disabled in scoring for this query instance. More...
virtual SimilarityPtr | getSimilarity (const SearcherPtr &searcher)
| Implement coord disabling. More...
void | setMinimumNumberShouldMatch (int32_t min)
| Specifies a minimum number of the optional BooleanClauses which must be satisfied. More...
int32_t | getMinimumNumberShouldMatch ()
| Gets the minimum number of the optional BooleanClauses which must be satisfied. More...
void | add (const QueryPtr &query, BooleanClause::Occur occur)
| Adds a clause to a boolean query. More...
void | add (const BooleanClausePtr &clause)
| Adds a clause to a boolean query. More...
Collection< BooleanClausePtr > | getClauses ()
| Returns the set of clauses in this query. More...
Collection< BooleanClausePtr >::iterator | begin ()
| Returns an iterator on the clauses in this query. More...
Collection< BooleanClausePtr >::iterator | end ()
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 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 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 LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr())
| Returns a clone of this query. 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 bool | equals (const LuceneObjectPtr &other)
| Return whether two objects are equal. More...
virtual int32_t | hashCode ()
| Return hash code for this object. 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 | combine (Collection< QueryPtr > queries)
| Called when re-writing queries under MultiSearcher. 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 int32_t | getMaxClauseCount ()
| Return the maximum number of clauses permitted, 1024 by default. Attempts to add more than the permitted number of clauses cause TooManyClauses to be thrown. More...
static void | setMaxClauseCount (int32_t maxClauseCount)
| Set the maximum number of clauses permitted per BooleanQuery. Default value is 1024. More...
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

Collection< BooleanClausePtr > | clauses
bool | disableCoord
int32_t | minNrShouldMatch
Protected Attributes inherited from Lucene::Query
double | boost
Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr | objectLock
LuceneSignalPtr | objectSignal

## Static Protected Attributes

static int32_t | maxClauseCount

## Additional Inherited Members

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

## Detailed Description

A Query that matches documents matching boolean combinations of other queries, eg. TermQuerys, PhraseQuerys or other BooleanQuerys.

## Constructor & Destructor Documentation

## ◆ BooleanQuery()

Lucene::BooleanQuery::BooleanQuery | ( | bool | disableCoord = `false` | ) |

Constructs an empty boolean query.

Similarity#coord(int32_t, int32_t) may be disabled in scoring, as appropriate. For example, this score factor does not make sense for most automatically generated queries, like WildcardQuery and FuzzyQuery.

Parameters

  disableCoord | disables Similarity#coord(int32_t, int32_t) in scoring.

## ◆ ~BooleanQuery()

virtual Lucene::BooleanQuery::~BooleanQuery | ( |  | ) |

virtual

## Member Function Documentation

## ◆ _getClassName()

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

inline static

## ◆ add() [1/2]

void Lucene::BooleanQuery::add | ( | const QueryPtr & | query,
|  | BooleanClause::Occur | occur
| ) |  |

Adds a clause to a boolean query.

See also
  getMaxClauseCount()

## ◆ add() [2/2]

void Lucene::BooleanQuery::add | ( | const BooleanClausePtr & | clause | ) |

Adds a clause to a boolean query.

See also
  getMaxClauseCount()

## ◆ begin()

Collection<BooleanClausePtr>::iterator Lucene::BooleanQuery::begin | ( |  | ) |

Returns an iterator on the clauses in this query.

## ◆ clone()

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

virtual

Returns a clone of this query.

Reimplemented from Lucene::Query.

## ◆ createWeight()

virtual WeightPtr Lucene::BooleanQuery::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.

## ◆ end()

Collection<BooleanClausePtr>::iterator Lucene::BooleanQuery::end | ( |  | ) |

## ◆ equals()

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

virtual

Return whether two objects are equal.

Reimplemented from Lucene::Query.

## ◆ extractTerms()

virtual void Lucene::BooleanQuery::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::BooleanQuery::getClassName | ( |  | ) |

inline virtual

Reimplemented from Lucene::Query.

## ◆ getClauses()

Collection<BooleanClausePtr> Lucene::BooleanQuery::getClauses | ( |  | ) |

Returns the set of clauses in this query.

## ◆ getMaxClauseCount()

static int32_t Lucene::BooleanQuery::getMaxClauseCount | ( |  | ) |

static

Return the maximum number of clauses permitted, 1024 by default. Attempts to add more than the permitted number of clauses cause TooManyClauses to be thrown.

See also
  setMaxClauseCount(int32_t)

## ◆ getMinimumNumberShouldMatch()

int32_t Lucene::BooleanQuery::getMinimumNumberShouldMatch | ( |  | ) |

Gets the minimum number of the optional BooleanClauses which must be satisfied.

## ◆ getSimilarity()

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

virtual

Implement coord disabling.

Reimplemented from Lucene::Query.

## ◆ hashCode()

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

virtual

Return hash code for this object.

Reimplemented from Lucene::Query.

## ◆ isCoordDisabled()

bool Lucene::BooleanQuery::isCoordDisabled | ( |  | ) |

Returns true if Similarity#coord(int32_t, int32_t) is disabled in scoring for this query instance.

See also
  BooleanQuery(bool)

## ◆ rewrite()

virtual QueryPtr Lucene::BooleanQuery::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 from Lucene::Query.

## ◆ setMaxClauseCount()

static void Lucene::BooleanQuery::setMaxClauseCount | ( | int32_t | maxClauseCount | ) |

static

Set the maximum number of clauses permitted per BooleanQuery. Default value is 1024.

## ◆ setMinimumNumberShouldMatch()

void Lucene::BooleanQuery::setMinimumNumberShouldMatch | ( | int32_t | min | ) |

Specifies a minimum number of the optional BooleanClauses which must be satisfied.

By default no optional clauses are necessary for a match (unless there are no required clauses). If this method is used, then the specified number of clauses is required.

Use of this method is totally independent of specifying that any specific clauses are required (or prohibited). This number will only be compared against the number of matching optional clauses.

Parameters

  min | the number of optional clauses that must match

## ◆ shared_from_this()

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

inline

## ◆ toString()

virtual String Lucene::BooleanQuery::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 from Lucene::Query.

## Field Documentation

## ◆ clauses

Collection<BooleanClausePtr> Lucene::BooleanQuery::clauses

protected

## ◆ disableCoord

bool Lucene::BooleanQuery::disableCoord

protected

## ◆ maxClauseCount

int32_t Lucene::BooleanQuery::maxClauseCount

static protected

## ◆ minNrShouldMatch

int32_t Lucene::BooleanQuery::minNrShouldMatch

protected

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

- BooleanQuery.h

clucene.sourceforge.net