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_PrefixQuery 00008 #define _lucene_search_PrefixQuery 00009 #if defined(_LUCENE_PRAGMA_ONCE) 00010 # pragma once 00011 #endif 00012 00013 #include "CLucene/index/Term.h" 00014 #include "CLucene/index/Terms.h" 00015 #include "CLucene/index/IndexReader.h" 00016 #include "SearchHeader.h" 00017 #include "BooleanQuery.h" 00018 #include "TermQuery.h" 00019 #include "CLucene/util/StringBuffer.h" 00020 00021 CL_NS_DEF(search) 00022 //PrefixQuery is a Query that matches documents containing terms with a specified prefix. 00023 00024 class PrefixQuery: public Query { 00025 private: 00026 CL_NS(index)::Term* prefix; 00027 protected: 00028 PrefixQuery(const PrefixQuery& clone); 00029 public: 00030 00031 //Constructor. Constructs a query for terms starting with prefix 00032 PrefixQuery(CL_NS(index)::Term* Prefix); 00033 00034 //Destructor 00035 ~PrefixQuery(); 00036 00037 //Returns the name "PrefixQuery" 00038 const TCHAR* getQueryName() const; 00039 static const TCHAR* getClassName(); 00040 00042 CL_NS(index)::Term* getPrefix(bool pointer=true); 00043 00044 Query* combine(Query** queries); 00045 Query* rewrite(CL_NS(index)::IndexReader* reader); 00046 Query* clone() const; 00047 bool equals(Query * other) const; 00048 00049 //Creates a user-readable version of this query and returns it as as string 00050 TCHAR* toString(const TCHAR* field) const; 00051 00052 size_t hashCode() const; 00053 }; 00054 00055 00056 class PrefixFilter: public Filter 00057 { 00058 private: 00059 CL_NS(index)::Term* prefix; 00060 protected: 00061 PrefixFilter( const PrefixFilter& copy ); 00062 00063 public: 00064 PrefixFilter(CL_NS(index)::Term* prefix); 00065 ~PrefixFilter(); 00066 00069 CL_NS(util)::BitSet* bits( CL_NS(index)::IndexReader* reader ); 00070 00071 Filter* clone() const; 00072 TCHAR* toString(); 00073 }; 00074 CL_NS_END 00075 #endif