2
* This file is part of Soprano Project.
4
* Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
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.
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.
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.
22
#ifndef _SOPRANO_INDEX_MODEL_FILTER_H_
23
#define _SOPRANO_INDEX_MODEL_FILTER_H_
25
#include "filtermodel.h"
26
#include "soprano_export.h"
40
* \class IndexFilterModel indexfiltermodel.h Soprano/Index/IndexFilterModel
42
* \brief The IndexFilterModel provides a full text index around any Soprano Model.
44
* All statements with a literal object will be indexed.
46
* \author Sebastian Trueg <trueg@kde.org>
48
class SOPRANO_INDEX_EXPORT IndexFilterModel : public Soprano::FilterModel
52
* Create a new index model.
54
* \param indexDir The directory where the index should be stored. If the
55
* directory already contains an index, it will be used. Otherwise a new
56
* one will be created.
57
* \param model The parent model to forward the calls to. If 0 the Model has to
58
* be set later on with FilterModel::setParentModel.
60
IndexFilterModel( const QString& indexDir, Soprano::Model* model = 0 );
63
* Create a new index model.
65
* \param index The index to be used. The filter model will NOT take ownership of
66
* the index. The caller has to take care of deleting the index.
67
* \param model The parent model to forward the calls to. If 0 the Model has to
68
* be set later on with FilterModel::setParentModel.
70
IndexFilterModel( CLuceneIndex* index, Soprano::Model* model = 0 );
78
* Retrieve the index used by this index model.
80
CLuceneIndex* index() const;
83
* Adds a new statement.
85
* This will index the statement and then forward the call to the parent model.
87
Soprano::Error::ErrorCode addStatement( const Soprano::Statement &statement );
90
* Removes a statement.
92
* This will remove the statement from the index and then forward the call to the parent model.
94
Soprano::Error::ErrorCode removeStatement( const Soprano::Statement &statement );
99
* This will remove the statements from the index and then forward the call to the parent model.
101
Soprano::Error::ErrorCode removeAllStatements( const Soprano::Statement &statement );
104
* The IndexFilterModel is currently based on CLucene. While the index itself is available
105
* via index() and allows querying via CLucene queries it is not available over the
106
* Soprano::Client interface.
107
* Thus, CLucene queries are supported through this method and will return QueryHit objects
108
* wrapped in a QueryResultIterator.
110
* Future versions of %Soprano will support querying the index through the Soprano::Query API
111
* (still unfinished and unstable).
113
* \param query The query string. This can be a CLucene query in which case the query will
114
* be passed to CLuceneIndex.
115
* \param language The query language. Set to Soprano::Query::QUERY_LANGUAGE_USER for
117
* \param userQueryLanguage If \p language equals Query::QUERY_LANGUAGE_USER
118
* userQueryLanguage defines the language to use. Use <b>"lucene"</b>
119
* to perform CLucene queries.
121
* \return An iterator over all results matching the query,
122
* on error an invalid iterator is returned. In case of a CLucene query the iterator will
123
* wrap a set of QueryHit objects through the bindings <b>"resource"</b> and <b>"score"</b>.
125
* \sa CLuceneIndex::search()
127
QueryResultIterator executeQuery( const QString& query, Query::QueryLanguage language, const QString& userQueryLanguage = QString() ) const;
130
* Extract full text matching parts of a %query and replace them with
131
* results from an index %query.
133
* \param query The query to rewrite.
135
* \return A rewritten query stripped of all full test and regexp matching parts
136
* and replaced by results from an index query.
138
// Query::Query evaluateAndRewriteQuery( const Query::Query& query ) const;