00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _SOPRANO_CLUCENE_INDEX_H_
00023 #define _SOPRANO_CLUCENE_INDEX_H_
00024
00025 #include <QtCore/QString>
00026
00027 #include "statement.h"
00028 #include "soprano_export.h"
00029 #include "error.h"
00030 #include "iterator.h"
00031 #include "indexqueryhit.h"
00032
00033
00034 namespace lucene {
00035 namespace search {
00036 class Hits;
00037 class Query;
00038 }
00039 namespace analysis {
00040 class Analyzer;
00041 }
00042 namespace document {
00043 class Document;
00044 class Field;
00045 }
00046 }
00047
00048 namespace Soprano {
00049
00050 namespace Index {
00051
00075 class SOPRANO_INDEX_EXPORT CLuceneIndex : public Error::ErrorCache
00076 {
00077 public:
00079
00082 CLuceneIndex( lucene::analysis::Analyzer* analyzer = 0 );
00083
00089 ~CLuceneIndex();
00091
00093
00099 bool open( const QString& folder, bool force = false );
00100
00104 void close();
00105
00110 bool isOpen() const;
00112
00114
00124 void setQueryAnalyzer( lucene::analysis::Analyzer* analyzer );
00125
00134 lucene::analysis::Analyzer* queryAnalyzer() const;
00136
00138
00144 int resourceCount() const;
00146
00148
00159 int startTransaction();
00160
00169 bool closeTransaction( int id );
00171
00173
00177 Error::ErrorCode addStatement( const Soprano::Statement& );
00178
00183 Error::ErrorCode removeStatement( const Soprano::Statement& );
00185
00187
00198 lucene::document::Document* documentForResource( const Node& resource );
00200
00202
00211 Iterator<QueryHit> search( const QString& query );
00212
00226 Iterator<QueryHit> search( lucene::search::Query* query );
00228
00229 #if 0
00230
00234 double getScore( const Soprano::Node& resource, const QString& query );
00235
00240 double getScore( const Soprano::Node& resource, lucene::search::Query* query );
00241 #endif
00242
00246 static Soprano::Node getResource( lucene::document::Document* document );
00247
00258 static QString defaultSearchField();
00259
00261
00264 void dump( QTextStream& ) const;
00265
00271 void clear();
00272
00279 void optimize();
00281
00282 private:
00283 class Private;
00284 Private* const d;
00285 };
00286 }
00287 }
00288
00289 #endif