Soprano  2.9.0
indexfiltermodel.h
Go to the documentation of this file.
1 /*
2  * This file is part of Soprano Project.
3  *
4  * Copyright (C) 2007-2008 Sebastian Trueg <trueg@kde.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef _SOPRANO_INDEX_MODEL_FILTER_H_
23 #define _SOPRANO_INDEX_MODEL_FILTER_H_
24 
25 #include "filtermodel.h"
26 #include "soprano_export.h"
27 
28 namespace Soprano {
29 
30  namespace Query {
31  class Query;
32  }
33 
44  namespace Index {
45 
46  class CLuceneIndex;
47  class QueryResult;
48  class IndexFilterModelPrivate;
49 
62  {
63  public:
73  IndexFilterModel( const QString& indexDir, Soprano::Model* model = 0 );
74 
83  IndexFilterModel( CLuceneIndex* index, Soprano::Model* model = 0 );
84 
89 
93  CLuceneIndex* index() const;
94 
102  Soprano::Error::ErrorCode addStatement( const Soprano::Statement &statement );
103 
109  Soprano::Error::ErrorCode removeStatement( const Soprano::Statement &statement );
110 
116  Soprano::Error::ErrorCode removeAllStatements( const Soprano::Statement &statement );
117 
142  QueryResultIterator executeQuery( const QString& query, Query::QueryLanguage language, const QString& userQueryLanguage = QString() ) const;
143 
144  /*
145  * Extract full text matching parts of a %query and replace them with
146  * results from an index %query.
147  *
148  * \param query The query to rewrite.
149  *
150  * \return A rewritten query stripped of all full test and regexp matching parts
151  * and replaced by results from an index query.
152  */
153 // Query::Query evaluateAndRewriteQuery( const Query::Query& query ) const;
154 
165  void setTransactionCacheSize( int size );
166 
172  int transactionCacheSize() const;
173 
182  void rebuildIndex();
183 
192  void optimizeIndex();
193 
206  void addIndexOnlyPredicate( const QUrl& predicate );
207 
220  void setIndexOnlyPredicates( const QList<QUrl>& predicates );
221 
235  QList<QUrl> indexOnlyPredicates() const;
236 
248  void addForceIndexPredicate( const QUrl& predicate );
249 
279  void setForceIndexPredicates( const QList<QUrl>& predicates );
280 
291  QList<QUrl> forceIndexPredicates() const;
292 
310  static QString encodeStringForLuceneQuery( const QString& value );
311 
329  static QString encodeUriForLuceneQuery( const QUrl& uri );
330 
334 
335  private:
336  IndexFilterModelPrivate* const d;
337  };
338  }
339 }
340 
341 #endif