CLucene - a full-featured, c++ search engine
API Documentation
00001 /*------------------------------------------------------------------------------ 00002 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 00003 * 00004 * Distributable under the terms of either the Apache License (Version 2.0) or 00005 * the GNU Lesser General Public License, as specified in the COPYING file. 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef _lucene_search_IndexSearcher_ 00008 #define _lucene_search_IndexSearcher_ 00009 00010 #if defined(_LUCENE_PRAGMA_ONCE) 00011 # pragma once 00012 #endif 00013 00014 #include "SearchHeader.h" 00015 #include "CLucene/store/Directory.h" 00016 #include "CLucene/document/Document.h" 00017 #include "CLucene/index/IndexReader.h" 00018 #include "CLucene/index/Term.h" 00019 #include "CLucene/util/BitSet.h" 00020 #include "HitQueue.h" 00021 #include "FieldSortedHitQueue.h" 00022 00023 CL_NS_DEF(search) 00029 class IndexSearcher:public Searcher{ 00030 CL_NS(index)::IndexReader* reader; 00031 bool readerOwner; 00032 00033 public: 00035 IndexSearcher(const char* path); 00036 00038 IndexSearcher(CL_NS(store)::Directory* directory); 00039 00041 IndexSearcher(CL_NS(index)::IndexReader* r); 00042 00043 ~IndexSearcher(); 00044 00046 void close(); 00047 00048 int32_t docFreq(const CL_NS(index)::Term* term) const; 00049 00050 bool doc(int32_t i, CL_NS(document)::Document* document); 00051 _CL_DEPRECATED( doc(i, document) ) CL_NS(document)::Document* doc(int32_t i); 00052 00053 int32_t maxDoc() const; 00054 00055 TopDocs* _search(Query* query, Filter* filter, const int32_t nDocs); 00056 TopFieldDocs* _search(Query* query, Filter* filter, const int32_t nDocs, const Sort* sort); 00057 00058 void _search(Query* query, Filter* filter, HitCollector* results); 00059 00060 CL_NS(index)::IndexReader* getReader(){ 00061 return reader; 00062 } 00063 00064 Query* rewrite(Query* original); 00065 void explain(Query* query, int32_t doc, Explanation* ret); 00066 }; 00067 CL_NS_END 00068 #endif