Soprano
2.7.5
|
00001 /* 00002 * This file is part of Soprano Project. 00003 * 00004 * Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public License 00017 * along with this library; see the file COPYING.LIB. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 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