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_TermQuery_ 00008 #define _lucene_search_TermQuery_ 00009 00010 #if defined(_LUCENE_PRAGMA_ONCE) 00011 # pragma once 00012 #endif 00013 00014 #include "SearchHeader.h" 00015 #include "Scorer.h" 00016 #include "CLucene/index/Term.h" 00017 #include "TermScorer.h" 00018 #include "CLucene/index/IndexReader.h" 00019 #include "CLucene/util/StringBuffer.h" 00020 #include "CLucene/index/Terms.h" 00021 00022 CL_NS_DEF(search) 00023 00024 00025 00028 class TermQuery: public Query { 00029 private: 00030 CL_NS(index)::Term* term; 00031 00032 00033 class TermWeight: public Weight { 00034 private: 00035 Searcher* searcher; 00036 float_t value; 00037 float_t idf; 00038 float_t queryNorm; 00039 float_t queryWeight; 00040 TermQuery* _this; 00041 CL_NS(index)::Term* _term; 00042 00043 public: 00044 TermWeight(Searcher* searcher, TermQuery* _this, CL_NS(index)::Term* _term); 00045 ~TermWeight(); 00046 TCHAR* toString(); 00047 Query* getQuery() { return (Query*)_this; } 00048 float_t getValue() { return value; } 00049 00050 float_t sumOfSquaredWeights(); 00051 void normalize(float_t queryNorm); 00052 Scorer* scorer(CL_NS(index)::IndexReader* reader); 00053 void explain(CL_NS(index)::IndexReader* reader, int32_t doc, Explanation* ret); 00054 }; 00055 00056 protected: 00057 Weight* _createWeight(Searcher* searcher); 00058 TermQuery(const TermQuery& clone); 00059 public: 00060 // Constructs a query for the term <code>t</code>. 00061 TermQuery(CL_NS(index)::Term* t); 00062 ~TermQuery(); 00063 00064 static const TCHAR* getClassName(); 00065 const TCHAR* getQueryName() const; 00066 00067 //added by search highlighter 00068 CL_NS(index)::Term* getTerm(bool pointer=true) const; 00069 00070 // Prints a user-readable version of this query. 00071 TCHAR* toString(const TCHAR* field) const; 00072 00073 bool equals(Query* other) const; 00074 Query* clone() const; 00075 00077 size_t hashCode() const; 00078 }; 00079 CL_NS_END 00080 #endif 00081