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_SearchHeader_ 00008 #define _lucene_search_SearchHeader_ 00009 00010 00011 //#include "CLucene/index/IndexReader.h" 00012 CL_CLASS_DEF(index,Term) 00013 CL_CLASS_DEF(index,IndexReader) 00014 //#include "Filter.h" 00015 CL_CLASS_DEF(document,Document) 00016 CL_CLASS_DEF(util,Comparable) 00017 //#include "Sort.h" 00018 //#include "CLucene/util/VoidList.h" 00019 //#include "Explanation.h" 00020 //#include "Similarity.h" 00021 00022 CL_NS_DEF(search) 00023 00024 class Query; 00025 class Scorer; 00026 class Explanation; 00027 class Hits; 00028 class Sort; 00029 class FieldDoc; 00030 class TopFieldDocs; 00031 00034 struct ScoreDoc { 00038 int32_t doc; 00039 00041 float_t score; 00042 }; 00043 00046 class TopDocs:LUCENE_BASE { 00047 public: 00051 int32_t totalHits; 00052 00054 ScoreDoc* scoreDocs; 00055 int32_t scoreDocsLength; 00056 00058 TopDocs(const int32_t th, ScoreDoc* sds, int32_t scoreDocsLength); 00059 ~TopDocs(); 00060 00061 private: 00063 //float_t maxScore; 00064 }; 00065 00066 // Lower-level search API. 00067 // @see Searcher#search(Query,HitCollector) 00068 class HitCollector: LUCENE_BASE { 00069 public: 00094 virtual void collect(const int32_t doc, const float_t score) = 0; 00095 virtual ~HitCollector(){} 00096 }; 00097 00107 class Weight: LUCENE_BASE { 00108 public: 00109 virtual ~Weight(){ 00110 }; 00111 00113 virtual Query* getQuery() = 0; 00114 00116 virtual float_t getValue() = 0; 00117 00119 virtual float_t sumOfSquaredWeights() = 0; 00120 00122 virtual void normalize(float_t norm) = 0; 00123 00125 virtual Scorer* scorer(CL_NS(index)::IndexReader* reader) = 0; 00126 00128 virtual void explain(CL_NS(index)::IndexReader* reader, int32_t doc, Explanation* ret) = 0; 00129 00130 virtual TCHAR* toString(); 00131 }; 00132 00133 class HitDoc:LUCENE_BASE { 00134 public: 00135 float_t score; 00136 int32_t id; 00137 CL_NS(document)::Document* doc; 00138 00139 HitDoc* next; // in doubly-linked cache 00140 HitDoc* prev; // in doubly-linked cache 00141 00142 HitDoc(const float_t s, const int32_t i); 00143 ~HitDoc(); 00144 }; 00145 00146 00147 CL_NS_END 00148 #endif