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_Hits_h 00008 #define _lucene_search_Hits_h 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 class Query; 00023 class Searcher; 00024 class Filter; 00025 class HitDoc; 00026 class Sort; 00027 00042 class CLUCENE_EXPORT Hits:LUCENE_BASE { 00043 private: 00044 Query* query; 00045 Searcher* searcher; 00046 Filter* filter; 00047 const Sort* sort; 00048 00049 size_t _length; // the total number of hits 00050 CL_NS(util)::CLVector<HitDoc*, CL_NS(util)::Deletor::Object<HitDoc> >* hitDocs; // cache of hits retrieved 00051 00052 HitDoc* first; // head of LRU cache 00053 HitDoc* last; // tail of LRU cache 00054 int32_t numDocs; // number cached 00055 int32_t maxDocs; // max to cache 00056 00057 int32_t nDeletions; // # deleted docs in the index. 00058 size_t _lengthAtStart; // this is the number apps usually count on (although deletions can bring it down). 00059 int32_t nDeletedHits; // # of already collected hits that were meanwhile deleted. 00060 00061 bool debugCheckedForDeletions; // for test purposes. 00062 00067 void getMoreDocs(const size_t _min); 00068 00070 HitDoc* getHitDoc(const size_t n); 00071 00072 void addToFront(HitDoc* hitDoc); 00073 00074 void remove(const HitDoc* hitDoc); 00075 00076 public: 00077 Hits(Searcher* s, Query* q, Filter* f, const Sort* sort=NULL); 00078 ~Hits(); 00079 00081 int32_t length() const; 00082 00089 CL_NS(document)::Document& doc(const int32_t n); 00090 00095 int32_t id (const int32_t n); 00096 00098 float_t score(const int32_t n); 00099 00101 int32_t countDeletions(CL_NS(search)::Searcher* s); 00102 }; 00103 00104 CL_NS_END 00105 #endif