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


Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
Lucene::MultiSearcher Class Reference

Implements search over a set of Searchables. More...

#include <MultiSearcher.h>

+ Inheritance diagram for Lucene::MultiSearcher:

Public Member Functions

 MultiSearcher (Collection< SearchablePtr > searchables)
 Creates a searcher which searches searchers.
 
virtual ~MultiSearcher ()
 
virtual String getClassName ()
 
boost::shared_ptr< MultiSearchershared_from_this ()
 
Collection< SearchablePtrgetSearchables ()
 Return the array of Searchables this searches.
 
virtual void close ()
 Frees resources associated with this Searcher. Be careful not to call this method while you are still using objects that reference this Searchable.
 
virtual int32_t docFreq (const TermPtr &term)
 Returns the number of documents containing term.
 
virtual DocumentPtr doc (int32_t n)
 Returns the stored fields of document i.
 
virtual DocumentPtr doc (int32_t n, const FieldSelectorPtr &fieldSelector)
 Get the Document at the n'th position. The FieldSelector may be used to determine what Fields to load and how they should be loaded.
 
int32_t subSearcher (int32_t n)
 Returns index of the searcher for document n in the array used to construct this searcher.
 
int32_t subDoc (int32_t n)
 Returns the document number of document n within its sub-index.
 
virtual int32_t maxDoc ()
 Returns one greater than the largest possible document number.
 
virtual TopDocsPtr search (const WeightPtr &weight, const FilterPtr &filter, int32_t n)
 Low-level search implementation. Finds the top n hits for query, applying filter if non-null. Applications should usually call Searcher#search(QueryPtr, int32_t) or Searcher#search(QueryPtr, FilterPtr, int32_t) instead.
 
virtual TopFieldDocsPtr search (const WeightPtr &weight, const FilterPtr &filter, int32_t n, const SortPtr &sort)
 Low-level search implementation with arbitrary sorting. Finds the top n hits for query, applying filter if non-null, and sorting the hits by the criteria in sort.
 
virtual void search (const WeightPtr &weight, const FilterPtr &filter, const CollectorPtr &results)
 Lower-level search API.
 
virtual QueryPtr rewrite (const QueryPtr &query)
 Called to re-write queries into primitive queries.
 
virtual ExplanationPtr explain (const WeightPtr &weight, int32_t doc)
 Low-level implementation method. Returns an Explanation that describes how doc scored against weight.
 
virtual TopFieldDocsPtr search (const QueryPtr &query, const FilterPtr &filter, int32_t n, const SortPtr &sort)
 Search implementation with arbitrary sorting. Finds the top n hits for query, applying filter if non-null, and sorting the hits by the criteria in sort.
 
virtual void search (const QueryPtr &query, const CollectorPtr &results)
 Lower-level search API.
 
virtual void search (const QueryPtr &query, const FilterPtr &filter, const CollectorPtr &results)
 Lower-level search API.
 
virtual TopDocsPtr search (const QueryPtr &query, const FilterPtr &filter, int32_t n)
 Finds the top n hits for query, applying filter if non-null.
 
virtual TopDocsPtr search (const QueryPtr &query, int32_t n)
 Finds the top n hits for query.
 
virtual void search (const WeightPtr &weight, const FilterPtr &filter, const CollectorPtr &results)=0
 Lower-level search API.
 
virtual TopDocsPtr search (const WeightPtr &weight, const FilterPtr &filter, int32_t n)=0
 Low-level search implementation. Finds the top n hits for query, applying filter if non-null. Applications should usually call Searcher#search(QueryPtr, int32_t) or Searcher#search(QueryPtr, FilterPtr, int32_t) instead.
 
virtual TopFieldDocsPtr search (const WeightPtr &weight, const FilterPtr &filter, int32_t n, const SortPtr &sort)=0
 Low-level search implementation with arbitrary sorting. Finds the top n hits for query, applying filter if non-null, and sorting the hits by the criteria in sort.
 
- Public Member Functions inherited from Lucene::Searcher
 Searcher ()
 
virtual ~Searcher ()
 
boost::shared_ptr< Searchershared_from_this ()
 
virtual ExplanationPtr explain (const QueryPtr &query, int32_t doc)
 Returns an Explanation that describes how doc scored against query.
 
virtual void setSimilarity (const SimilarityPtr &similarity)
 Set the Similarity implementation used by this Searcher.
 
virtual SimilarityPtr getSimilarity ()
 Return the Similarity implementation used by this Searcher.
 
virtual Collection< int32_t > docFreqs (Collection< TermPtr > terms)
 For each term in the terms array, calculates the number of documents containing term. Returns an array with these document frequencies. Used to minimize number of remote calls.
 
- Public Member Functions inherited from Lucene::Searchable
virtual ~Searchable ()
 
- 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 LuceneObjectPtr clone (const LuceneObjectPtr &other=LuceneObjectPtr())
 Return clone of this object.
 
virtual int32_t hashCode ()
 Return hash code for this object.
 
virtual bool equals (const LuceneObjectPtr &other)
 Return whether two objects are equal.
 
virtual int32_t compareTo (const LuceneObjectPtr &other)
 Compare two objects.
 
virtual String toString ()
 Returns a string representation of the object.
 
- 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 Public Member Functions inherited from Lucene::Searcher
static String _getClassName ()
 
- Static Public Member Functions inherited from Lucene::Searchable
static String _getClassName ()
 

Protected Member Functions

Collection< int32_t > getStarts ()
 
virtual WeightPtr createWeight (const QueryPtr &query)
 Create weight in multiple index scenario.
 
- Protected Member Functions inherited from Lucene::LuceneObject
 LuceneObject ()
 

Protected Attributes

Collection< SearchablePtrsearchables
 
Collection< int32_t > starts
 
int32_t _maxDoc
 
- Protected Attributes inherited from Lucene::Searcher
SimilarityPtr similarity
 The Similarity implementation used by this searcher.
 
- Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr objectLock
 
LuceneSignalPtr objectSignal
 

Detailed Description

Implements search over a set of Searchables.

Applications usually need only call the inherited search(QueryPtr, int32_t) or search(QueryPtr, FilterPtr, int32_t) methods.

Constructor & Destructor Documentation

◆ MultiSearcher()

Lucene::MultiSearcher::MultiSearcher ( Collection< SearchablePtr searchables)

Creates a searcher which searches searchers.

◆ ~MultiSearcher()

virtual Lucene::MultiSearcher::~MultiSearcher ( )
virtual

Member Function Documentation

◆ _getClassName()

static String Lucene::MultiSearcher::_getClassName ( )
inlinestatic

◆ close()

virtual void Lucene::MultiSearcher::close ( )
virtual

Frees resources associated with this Searcher. Be careful not to call this method while you are still using objects that reference this Searchable.

Implements Lucene::Searcher.

◆ createWeight()

virtual WeightPtr Lucene::MultiSearcher::createWeight ( const QueryPtr query)
protectedvirtual

Create weight in multiple index scenario.

Distributed query processing is done in the following steps:

  1. rewrite query.
  2. extract necessary terms.
  3. collect dfs for these terms from the Searchables.
  4. create query weight using aggregate dfs.
  5. distribute that weight to Searchables.
  6. merge results.

Steps 1-4 are done here, 5+6 in the search() methods

Returns
rewritten queries

Reimplemented from Lucene::Searcher.

◆ doc() [1/2]

virtual DocumentPtr Lucene::MultiSearcher::doc ( int32_t  n)
virtual

Returns the stored fields of document i.

See also
IndexReader::document(int32_t)

Implements Lucene::Searcher.

◆ doc() [2/2]

virtual DocumentPtr Lucene::MultiSearcher::doc ( int32_t  n,
const FieldSelectorPtr fieldSelector 
)
virtual

Get the Document at the n'th position. The FieldSelector may be used to determine what Fields to load and how they should be loaded.

NOTE: If the underlying Reader (more specifically, the underlying FieldsReader) is closed before the lazy Field is loaded an exception may be thrown. If you want the value of a lazy Field to be available after closing you must explicitly load it or fetch the Document again with a new loader.

Parameters
nGet the document at the n'th position
fieldSelectorThe FieldSelector to use to determine what Fields should be loaded on the Document. May be null, in which case all Fields will be loaded.
Returns
The stored fields of the Document at the n'th position
See also
IndexReader::document(int32_t, FieldSelectorPtr)
Fieldable
FieldSelector
SetBasedFieldSelector
LoadFirstFieldSelector

Implements Lucene::Searcher.

◆ docFreq()

virtual int32_t Lucene::MultiSearcher::docFreq ( const TermPtr term)
virtual

Returns the number of documents containing term.

See also
IndexReader::docFreq(TermPtr)

Implements Lucene::Searcher.

Reimplemented in Lucene::ParallelMultiSearcher.

◆ explain()

virtual ExplanationPtr Lucene::MultiSearcher::explain ( const WeightPtr weight,
int32_t  doc 
)
virtual

Low-level implementation method. Returns an Explanation that describes how doc scored against weight.

This is intended to be used in developing Similarity implementations, and for good performance, should not be displayed with every hit. Computing an explanation is as expensive as executing the query over the entire index.

Applications should call Searcher#explain(QueryPtr, int32_t).

Implements Lucene::Searcher.

◆ getClassName()

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

Reimplemented from Lucene::Searcher.

Reimplemented in Lucene::ParallelMultiSearcher.

◆ getSearchables()

Collection< SearchablePtr > Lucene::MultiSearcher::getSearchables ( )

Return the array of Searchables this searches.

◆ getStarts()

Collection< int32_t > Lucene::MultiSearcher::getStarts ( )
protected

◆ maxDoc()

virtual int32_t Lucene::MultiSearcher::maxDoc ( )
virtual

Returns one greater than the largest possible document number.

See also
IndexReader::maxDoc()

Implements Lucene::Searcher.

◆ rewrite()

virtual QueryPtr Lucene::MultiSearcher::rewrite ( const QueryPtr query)
virtual

Called to re-write queries into primitive queries.

Implements Lucene::Searcher.

◆ search() [1/11]

virtual void Lucene::Searcher::search ( const QueryPtr query,
const CollectorPtr results 
)
virtual

Lower-level search API.

Collector#collect(int32_t) is called for every matching document.

Applications should only use this if they need all of the matching documents. The high-level search API (Searcher#search(QueryPtr, int32_t)) is usually more efficient, as it skips non-high-scoring hits.

Note: The score passed to this method is a raw score. In other words, the score will not necessarily be a double whose value is between 0 and 1.

Reimplemented from Lucene::Searcher.

◆ search() [2/11]

virtual void Lucene::Searcher::search ( const QueryPtr query,
const FilterPtr filter,
const CollectorPtr results 
)
virtual

Lower-level search API.

Collector#collect(int32_t) is called for every matching document. Collector-based access to remote indexes is discouraged.

Applications should only use this if they need all of the matching documents. The high-level search API (Searcher#search(QueryPtr, FilterPtr, int32_t)) is usually more efficient, as it skips non-high-scoring hits.

Parameters
queryTo match documents
filterIf non-null, used to permit documents to be collected.
resultsTo receive hits

Reimplemented from Lucene::Searcher.

◆ search() [3/11]

virtual TopDocsPtr Lucene::Searcher::search ( const QueryPtr query,
const FilterPtr filter,
int32_t  n 
)
virtual

Finds the top n hits for query, applying filter if non-null.

Reimplemented from Lucene::Searcher.

◆ search() [4/11]

virtual TopFieldDocsPtr Lucene::Searcher::search ( const QueryPtr query,
const FilterPtr filter,
int32_t  n,
const SortPtr sort 
)
virtual

Search implementation with arbitrary sorting. Finds the top n hits for query, applying filter if non-null, and sorting the hits by the criteria in sort.

NOTE: this does not compute scores by default; use IndexSearcher#setDefaultFieldSortScoring to enable scoring.

Reimplemented from Lucene::Searcher.

◆ search() [5/11]

virtual TopDocsPtr Lucene::Searcher::search ( const QueryPtr query,
int32_t  n 
)
virtual

Finds the top n hits for query.

Reimplemented from Lucene::Searcher.

◆ search() [6/11]

virtual void Lucene::MultiSearcher::search ( const WeightPtr weight,
const FilterPtr filter,
const CollectorPtr collector 
)
virtual

Lower-level search API.

Collector#collect(int32_t) is called for every document. Collector-based access to remote indexes is discouraged.

Applications should only use this if they need all of the matching documents. The high-level search API (Searcher#search(QueryPtr, int32_t)) is usually more efficient, as it skips non-high-scoring hits.

Parameters
weightTo match documents
filterIf non-null, used to permit documents to be collected.
collectorTo receive hits

Implements Lucene::Searcher.

◆ search() [7/11]

virtual void Lucene::Searcher::search ( const WeightPtr weight,
const FilterPtr filter,
const CollectorPtr collector 
)
virtual

Lower-level search API.

Collector#collect(int32_t) is called for every document. Collector-based access to remote indexes is discouraged.

Applications should only use this if they need all of the matching documents. The high-level search API (Searcher#search(QueryPtr, int32_t)) is usually more efficient, as it skips non-high-scoring hits.

Parameters
weightTo match documents
filterIf non-null, used to permit documents to be collected.
collectorTo receive hits

Implements Lucene::Searcher.

◆ search() [8/11]

virtual TopDocsPtr Lucene::MultiSearcher::search ( const WeightPtr weight,
const FilterPtr filter,
int32_t  n 
)
virtual

Low-level search implementation. Finds the top n hits for query, applying filter if non-null. Applications should usually call Searcher#search(QueryPtr, int32_t) or Searcher#search(QueryPtr, FilterPtr, int32_t) instead.

Implements Lucene::Searcher.

Reimplemented in Lucene::ParallelMultiSearcher.

◆ search() [9/11]

virtual TopDocsPtr Lucene::Searcher::search ( const WeightPtr weight,
const FilterPtr filter,
int32_t  n 
)
virtual

Low-level search implementation. Finds the top n hits for query, applying filter if non-null. Applications should usually call Searcher#search(QueryPtr, int32_t) or Searcher#search(QueryPtr, FilterPtr, int32_t) instead.

Implements Lucene::Searcher.

Reimplemented in Lucene::ParallelMultiSearcher.

◆ search() [10/11]

virtual TopFieldDocsPtr Lucene::MultiSearcher::search ( const WeightPtr weight,
const FilterPtr filter,
int32_t  n,
const SortPtr sort 
)
virtual

Low-level search implementation with arbitrary sorting. Finds the top n hits for query, applying filter if non-null, and sorting the hits by the criteria in sort.

Applications should usually call Searcher#search(QueryPtr, FilterPtr, int32_t, SortPtr) instead.

Implements Lucene::Searcher.

Reimplemented in Lucene::ParallelMultiSearcher.

◆ search() [11/11]

virtual TopFieldDocsPtr Lucene::Searcher::search ( const WeightPtr weight,
const FilterPtr filter,
int32_t  n,
const SortPtr sort 
)
virtual

Low-level search implementation with arbitrary sorting. Finds the top n hits for query, applying filter if non-null, and sorting the hits by the criteria in sort.

Applications should usually call Searcher#search(QueryPtr, FilterPtr, int32_t, SortPtr) instead.

Implements Lucene::Searcher.

Reimplemented in Lucene::ParallelMultiSearcher.

◆ shared_from_this()

boost::shared_ptr< MultiSearcher > Lucene::MultiSearcher::shared_from_this ( )
inline

◆ subDoc()

int32_t Lucene::MultiSearcher::subDoc ( int32_t  n)

Returns the document number of document n within its sub-index.

◆ subSearcher()

int32_t Lucene::MultiSearcher::subSearcher ( int32_t  n)

Returns index of the searcher for document n in the array used to construct this searcher.

Field Documentation

◆ _maxDoc

int32_t Lucene::MultiSearcher::_maxDoc
protected

◆ searchables

Collection<SearchablePtr> Lucene::MultiSearcher::searchables
protected

◆ starts

Collection<int32_t> Lucene::MultiSearcher::starts
protected

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

clucene.sourceforge.net