soprano
Soprano::Index::IndexFilterModel Class Reference
The IndexFilterModel provides a full text index around any Soprano Model. More...
#include <Soprano/Index/IndexFilterModel>

Detailed Description
The IndexFilterModel provides a full text index around any Soprano Model.
All statements with a literal object will be indexed. The literals can then be searched with CLucene queries. More details regarding queries can be found in the documentation fo executeQuery().
Definition at line 61 of file indexfiltermodel.h.
Constructor & Destructor Documentation
| Soprano::Index::IndexFilterModel::IndexFilterModel | ( | const QString & | indexDir, | |
| Soprano::Model * | model = 0 | |||
| ) |
Create a new index model.
- Parameters:
-
indexDir The directory where the index should be stored. If the directory already contains an index, it will be used. Otherwise a new one will be created. model The parent model to forward the calls to. If 0 the Model has to be set later on with FilterModel::setParentModel.
| Soprano::Index::IndexFilterModel::IndexFilterModel | ( | CLuceneIndex * | index, | |
| Soprano::Model * | model = 0 | |||
| ) |
Create a new index model.
- Parameters:
-
index The index to be used. The filter model will NOT take ownership of the index. The caller has to take care of deleting the index. model The parent model to forward the calls to. If 0 the Model has to be set later on with FilterModel::setParentModel.
| Soprano::Index::IndexFilterModel::~IndexFilterModel | ( | ) |
Destructor.
Member Function Documentation
| void Soprano::Index::IndexFilterModel::addForceIndexPredicate | ( | const QUrl & | predicate | ) |
Add a predicate which should be indexed even if the object is a resource.
See setForceIndexPredicates for a detailed explanation.
- Parameters:
-
predicate The predicate that should be indexed in any case.
- See also:
- forceIndexPredicates, setForceIndexPredicates
- Since:
- 2.2
| void Soprano::Index::IndexFilterModel::addIndexOnlyPredicate | ( | const QUrl & | predicate | ) |
Add a predicate which should only be indexed.
This might be useful for very large literals whose value is of no interest but which should be searchable.
- Parameters:
-
predicate The predicate that should only be indexed but not stored in the underlying Model.
- See also:
- indexOnlyPredicates, setIndexOnlyPredicates
- Since:
- 2.1
| Soprano::Error::ErrorCode Soprano::Index::IndexFilterModel::addStatement | ( | const Soprano::Statement & | statement | ) | [virtual] |
Adds a new statement.
This will index the statement and then forward the call to the parent model. Normally only statements with literal objects are indexed. An exception are those statements with predicates that are set via setForceIndexPredicates.
Reimplemented from Soprano::FilterModel.
| static QString Soprano::Index::IndexFilterModel::encodeStringForLuceneQuery | ( | const QString & | value | ) | [static] |
Encodes a string to be used in a lucene query.
String values may contain characters that are reserved in lucene queries. These are property escaped by this method.
This method converts an arbitrary string into a string that can be used in a lucene query.
- Parameters:
-
value The string to be encoded.
- Returns:
- An encoded and escaped string representation of the provided string.
- See also:
- encodeUriForLuceneQuery
- Since:
- 2.2
| static QString Soprano::Index::IndexFilterModel::encodeUriForLuceneQuery | ( | const QUrl & | uri | ) | [static] |
Encodes a URI to be used in a lucene query.
URIs often contain characters that are reserved in lucene queries and, thus, need to be escaped. In addition, the URIs are encoded by the index model for storage in clucene.
This method converts a URI into a string that can be used in a lucene query.
- Parameters:
-
uri The URI to be encoded.
- Returns:
- An encoded and escaped string representation of the URI.
- See also:
- encodeStringForLuceneQuery
- Since:
- 2.2
| QueryResultIterator Soprano::Index::IndexFilterModel::executeQuery | ( | const QString & | query, | |
| Query::QueryLanguage | language, | |||
| const QString & | userQueryLanguage = QString() | |||
| ) | const [virtual] |
The IndexFilterModel is currently based on CLucene.
While the index itself is available via index() and allows querying via CLucene queries it is not available over the Soprano::Client interface. Thus, CLucene queries are supported through this method and will return QueryHit objects wrapped in a QueryResultIterator.
Future versions of Soprano will support querying the index through the Soprano::Query API (still unfinished and unstable).
- Parameters:
-
query The query string. This can be a CLucene query in which case the query will be passed to CLuceneIndex. language The query language. Set to Soprano::Query::QueryLanguageUser for CLucene queries. userQueryLanguage If languageequals Query::QueryLanguageUser userQueryLanguage defines the language to use. Use "lucene" to perform CLucene queries.
- Returns:
- An iterator over all results matching the query, on error an invalid iterator is returned. In case of a CLucene query the iterator will wrap a set of QueryHit objects through the bindings "resource" and "score".
- See also:
- CLuceneIndex::search()
Reimplemented from Soprano::FilterModel.
See setForceIndexPredicates for a detailed explanation.
- Returns:
- A list of predicates that will be indexed even if the object is not a literal.
- Since:
- 2.2
| CLuceneIndex* Soprano::Index::IndexFilterModel::index | ( | ) | const |
Retrieve the index used by this index model.
The IndexFilterModel supports to not forward certain predicates to the parent Model but only index their value.
This might be useful for very large literals whose value is of no interest but which should be searchable.
- Returns:
- A list of predicates that will only be indexed but not stored in the underlying Model.
- See also:
- addIndexOnlyPredicate, setIndexOnlyPredicates
- Since:
- 2.1
| void Soprano::Index::IndexFilterModel::optimizeIndex | ( | ) |
Optimize the index for search.
This makes sense after adding or removing a large number of statements.
- See also:
- CLuceneIndex::optimize
- Since:
- 2.2
| void Soprano::Index::IndexFilterModel::rebuildIndex | ( | ) |
Rebuild the complete index.
This means that the index will be cleared and all literal statements will be re-indexed.
This method is purely intended for maintenance.
- Since:
- 2.1
| Soprano::Error::ErrorCode Soprano::Index::IndexFilterModel::removeAllStatements | ( | const Soprano::Statement & | statement | ) | [virtual] |
Removes statements.
This will remove the statements from the index and then forward the call to the parent model.
Reimplemented from Soprano::FilterModel.
| Soprano::Error::ErrorCode Soprano::Index::IndexFilterModel::removeStatement | ( | const Soprano::Statement & | statement | ) | [virtual] |
Removes a statement.
This will remove the statement from the index and then forward the call to the parent model.
Reimplemented from Soprano::FilterModel.
Normally only statements with a literal object are indexed when added thorugh addStatement.
In some cases however, it is useful to also index resource objects.
Statement with a resource object (a URI) and a predicate that matches one of the force index predicates, are converted to strings using QUrl::toEncoded and added to the index non-tokenized. Thus, the resources will be searchable directly via a 'field:uri' query but not via the default search field.
A typical and very useful predicate is Vocabulary::RDF::type(). This allows to restrict the type of resources in lucene queries:
model->executeQuery( QString( "foobar AND %1:%2" ) .arg( encodeUriForLuceneQuery( RDF::type() ) ) .arg( encodeUriForLuceneQuery( myType ) ), Query::QueryLanguageUser, "lucene" );
- Parameters:
-
predicates The predicates that should be indexed in any case.
- See also:
- forceIndexPredicates, addForceIndexPredicate
- Since:
- 2.2
Set the predicates that should only be indexed.
This might be useful for very large literals whose value is of no interest but which should be searchable.
- Parameters:
-
predicates A list of predicates that should only be indexed but not stored in the underlying Model.
- See also:
- indexOnlyPredicates, addIndexOnlyPredicate
- Since:
- 2.1
| void Soprano::Index::IndexFilterModel::setTransactionCacheSize | ( | int | size | ) |
Set the number or addStatement operations that are to be cached in the index.
The default value is 1 which means that no caching occurs. Be aware that query operations will always close cached transactions.
- Parameters:
-
size The number of operations that should be handled in one transaction. Set to 1 to disable.
| int Soprano::Index::IndexFilterModel::transactionCacheSize | ( | ) | const |
The number of addStatement operations to cache in one transaction.
- See also:
- setTransactionCacheSize
The documentation for this class was generated from the following file:
KDE 4.4 API Reference