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

Loading...
Searching...
No Matches
IndexSearcher.h
Go to the documentation of this file.
1
2// Copyright (c) 2009-2014 Alan Wright. All rights reserved.
3// Distributable under the terms of either the Apache License (Version 2.0)
4// or the GNU Lesser General Public License.
6
7#ifndef INDEXSEARCHER_H
8#define INDEXSEARCHER_H
9
10#include "Searcher.h"
11
12 namespace Lucene {
13
23 class LPPAPI IndexSearcher : public Searcher {
24 public:
30 IndexSearcher(const DirectoryPtr& path, bool readOnly = true);
31
33 IndexSearcher(const IndexReaderPtr& reader);
34
36 IndexSearcher(const IndexReaderPtr& reader, Collection<IndexReaderPtr> subReaders, Collection<int32_t> docStarts);
37
38 virtual ~IndexSearcher();
39
40 LUCENE_CLASS(IndexSearcher);
41
42 public:
43 IndexReaderPtr reader;
44
45 protected:
46 bool closeReader;
47
48 Collection<IndexReaderPtr> subReaders;
49 Collection<int32_t> docStarts;
50
51 bool fieldSortDoTrackScores;
52 bool fieldSortDoMaxScore;
53
54 public:
56 IndexReaderPtr getIndexReader();
57
61 virtual void close();
62
63 virtual int32_t docFreq(const TermPtr& term);
64 virtual DocumentPtr doc(int32_t n);
65 virtual DocumentPtr doc(int32_t n, const FieldSelectorPtr& fieldSelector);
66 virtual int32_t maxDoc();
67
68 using Searcher::search;
69 using Searcher::explain;
70
71 virtual TopDocsPtr search(const WeightPtr& weight, const FilterPtr& filter, int32_t n);
72 virtual TopFieldDocsPtr search(const WeightPtr& weight, const FilterPtr& filter, int32_t n, const SortPtr& sort);
73
80 virtual TopFieldDocsPtr search(const WeightPtr& weight, const FilterPtr& filter, int32_t n, const SortPtr& sort, bool fillFields);
81
82 virtual void search(const WeightPtr& weight, const FilterPtr& filter, const CollectorPtr& results);
83 virtual QueryPtr rewrite(const QueryPtr& query);
84 virtual ExplanationPtr explain(const WeightPtr& weight, int32_t doc);
85
92 virtual void setDefaultFieldSortScoring(bool doTrackScores, bool doMaxScore);
93
94 protected:
95 void ConstructSearcher(const IndexReaderPtr& reader, bool closeReader);
96 void gatherSubReaders(Collection<IndexReaderPtr> allSubReaders, const IndexReaderPtr& reader);
97 void searchWithFilter(const IndexReaderPtr& reader, const WeightPtr& weight, const FilterPtr& filter, const CollectorPtr& collector);
98};
99
100}
101
102#endif
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Searcher.h
Lucene::Collection
Utility template class to handle collections that can be safely copied and shared.
Definition Collection.h:17
Lucene::IndexSearcher
Implements search over a single IndexReader.
Definition IndexSearcher.h:23
Lucene::IndexSearcher::search
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....
Lucene::IndexSearcher::IndexSearcher
IndexSearcher(const DirectoryPtr &path, bool readOnly=true)
Creates a searcher searching the index in the named directory. You should pass readOnly = true,...
Lucene::IndexSearcher::maxDoc
virtual int32_t maxDoc()
Returns one greater than the largest possible document number.
Lucene::IndexSearcher::search
virtual void search(const WeightPtr &weight, const FilterPtr &filter, const CollectorPtr &results)
Lower-level search API.
Lucene::IndexSearcher::fieldSortDoMaxScore
bool fieldSortDoMaxScore
Definition IndexSearcher.h:52
Lucene::IndexSearcher::ConstructSearcher
void ConstructSearcher(const IndexReaderPtr &reader, bool closeReader)
Lucene::IndexSearcher::explain
virtual ExplanationPtr explain(const WeightPtr &weight, int32_t doc)
Low-level implementation method. Returns an Explanation that describes how doc scored against weight.
Lucene::IndexSearcher::setDefaultFieldSortScoring
virtual void setDefaultFieldSortScoring(bool doTrackScores, bool doMaxScore)
By default, no scores are computed when sorting by field (using search(QueryPtr, FilterPtr,...
Lucene::IndexSearcher::reader
IndexReaderPtr reader
Definition IndexSearcher.h:43
Lucene::IndexSearcher::rewrite
virtual QueryPtr rewrite(const QueryPtr &query)
Called to re-write queries into primitive queries.
Lucene::IndexSearcher::docFreq
virtual int32_t docFreq(const TermPtr &term)
Returns the number of documents containing term.
Lucene::IndexSearcher::subReaders
Collection< IndexReaderPtr > subReaders
Definition IndexSearcher.h:48
Lucene::IndexSearcher::~IndexSearcher
virtual ~IndexSearcher()
Lucene::IndexSearcher::doc
virtual DocumentPtr doc(int32_t n)
Returns the stored fields of document i.
Lucene::IndexSearcher::searchWithFilter
void searchWithFilter(const IndexReaderPtr &reader, const WeightPtr &weight, const FilterPtr &filter, const CollectorPtr &collector)
Lucene::IndexSearcher::IndexSearcher
IndexSearcher(const IndexReaderPtr &reader, Collection< IndexReaderPtr > subReaders, Collection< int32_t > docStarts)
Directly specify the reader, subReaders and their docID starts.
Lucene::IndexSearcher::close
virtual void close()
Note that the underlying IndexReader is not closed, if IndexSearcher was constructed with IndexSearch...
Lucene::IndexSearcher::docStarts
Collection< int32_t > docStarts
Definition IndexSearcher.h:49
Lucene::IndexSearcher::IndexSearcher
IndexSearcher(const IndexReaderPtr &reader)
Creates a searcher searching the provided index.
Lucene::IndexSearcher::closeReader
bool closeReader
Definition IndexSearcher.h:46
Lucene::IndexSearcher::search
virtual TopFieldDocsPtr search(const WeightPtr &weight, const FilterPtr &filter, int32_t n, const SortPtr &sort, bool fillFields)
Just like search(WeightPtr, FilterPtr, int32_t, SortPtr), but you choose whether or not the fields in...
Lucene::IndexSearcher::fieldSortDoTrackScores
bool fieldSortDoTrackScores
Definition IndexSearcher.h:51
Lucene::IndexSearcher::gatherSubReaders
void gatherSubReaders(Collection< IndexReaderPtr > allSubReaders, const IndexReaderPtr &reader)
Lucene::IndexSearcher::search
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,...
Lucene::IndexSearcher::getIndexReader
IndexReaderPtr getIndexReader()
Return the IndexReader this searches.
Lucene::IndexSearcher::doc
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...
Lucene::Searcher
An abstract base class for search implementations. Implements the main search methods.
Definition Searcher.h:18
Lucene
Definition AbstractAllTermDocs.h:12
Lucene::TopDocsPtr
boost::shared_ptr< TopDocs > TopDocsPtr
Definition LuceneTypes.h:471
Lucene::QueryPtr
boost::shared_ptr< Query > QueryPtr
Definition LuceneTypes.h:420
Lucene::FieldSelectorPtr
boost::shared_ptr< FieldSelector > FieldSelectorPtr
Definition LuceneTypes.h:77
Lucene::TermPtr
boost::shared_ptr< Term > TermPtr
Definition LuceneTypes.h:233
Lucene::CollectorPtr
boost::shared_ptr< Collector > CollectorPtr
Definition LuceneTypes.h:295
Lucene::ExplanationPtr
boost::shared_ptr< Explanation > ExplanationPtr
Definition LuceneTypes.h:333
Lucene::SortPtr
boost::shared_ptr< Sort > SortPtr
Definition LuceneTypes.h:442
Lucene::DirectoryPtr
boost::shared_ptr< Directory > DirectoryPtr
Definition LuceneTypes.h:489
Lucene::TopFieldDocsPtr
boost::shared_ptr< TopFieldDocs > TopFieldDocsPtr
Definition LuceneTypes.h:474
Lucene::IndexReaderPtr
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition LuceneTypes.h:157
Lucene::DocumentPtr
boost::shared_ptr< Document > DocumentPtr
Definition LuceneTypes.h:74
Lucene::FilterPtr
boost::shared_ptr< Filter > FilterPtr
Definition LuceneTypes.h:358
Lucene::WeightPtr
boost::shared_ptr< Weight > WeightPtr
Definition LuceneTypes.h:480

clucene.sourceforge.net