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_Searcher_ 00008 #define _lucene_search_Searcher_ 00009 00010 00011 //#include "CLucene/index/IndexReader.h" 00012 CL_CLASS_DEF(index,Term) 00013 //#include "Filter.h" 00014 CL_CLASS_DEF(document,Document) 00015 //#include "Sort.h" 00016 //#include "CLucene/util/VoidList.h" 00017 //#include "Explanation.h" 00018 //#include "Similarity.h" 00019 00020 CL_NS_DEF(search) 00021 00022 //predefine classes 00023 class Query; 00024 class Filter; 00025 class HitCollector; 00026 class TopDocs; 00027 class Explanation; 00028 class Hits; 00029 class Similarity; 00030 class TopFieldDocs; 00031 class Sort; 00032 00033 00039 class CLUCENE_EXPORT Searchable: LUCENE_BASE { 00040 public: 00041 virtual ~Searchable(); 00042 00057 virtual void _search(Query* query, Filter* filter, HitCollector* results) = 0; 00058 00063 virtual void close() = 0; 00064 00069 virtual int32_t docFreq(const CL_NS(index)::Term* term) const = 0; 00070 00075 virtual int32_t maxDoc() const = 0; 00076 00085 virtual TopDocs* _search(Query* query, Filter* filter, const int32_t n) = 0; 00086 00091 virtual bool doc(int32_t i, CL_NS(document)::Document* d) = 0; 00092 _CL_DEPRECATED( doc(i, document) ) CL_NS(document)::Document* doc(const int32_t i); 00093 00095 virtual Query* rewrite(Query* query) = 0; 00096 00105 virtual void explain(Query* query, int32_t doc, Explanation* ret) = 0; 00106 00115 virtual TopFieldDocs* _search(Query* query, Filter* filter, const int32_t n, const Sort* sort) = 0; 00116 }; 00117 00118 00119 00123 class CLUCENE_EXPORT Searcher:public Searchable { 00124 private: 00126 Similarity* similarity; 00127 public: 00128 Searcher(); 00129 virtual ~Searcher(); 00130 00131 // Returns the documents matching <code>query</code>. 00132 Hits* search(Query* query); 00133 00134 // Returns the documents matching <code>query</code> and 00135 // <code>filter</code>. 00136 Hits* search(Query* query, Filter* filter); 00137 00141 Hits* search(Query* query, const Sort* sort); 00142 00146 Hits* search(Query* query, Filter* filter, const Sort* sort); 00147 00161 void _search(Query* query, HitCollector* results); 00162 00167 void setSimilarity(Similarity* similarity); 00168 00173 Similarity* getSimilarity(); 00174 00175 virtual const TCHAR* getClassName(); 00176 00177 virtual void _search(Query* query, Filter* filter, HitCollector* results) = 0; 00178 }; 00179 00180 CL_NS_END 00181 #endif