• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE Support
  • Sitemap
  • Contact Us
 

soprano

Soprano::Index::CLuceneIndex

Soprano::Index::CLuceneIndex Class Reference

The CLuceneIndex provides a wrapper around a CLucene index which stores RDF statements. More...

#include <Soprano/Index/CLuceneIndex>

Inheritance diagram for Soprano::Index::CLuceneIndex:
Inheritance graph
[legend]

List of all members.

Public Member Functions



 CLuceneIndex (lucene::analysis::Analyzer *analyzer=0)
 ~CLuceneIndex ()
Error::ErrorCode addStatement (const Soprano::Statement &)
void clear ()
void close ()
bool closeTransaction (int id)
lucene::document::Document * documentForResource (const Node &resource)
void dump (QTextStream &) const
bool isOpen () const
bool open (const QString &folder, bool force=false)
void optimize ()
lucene::analysis::Analyzer * queryAnalyzer () const
Error::ErrorCode removeStatement (const Soprano::Statement &)
int resourceCount () const
Iterator< QueryHit > search (lucene::search::Query *query)
Iterator< QueryHit > search (const QString &query)
void setQueryAnalyzer (lucene::analysis::Analyzer *analyzer)
int startTransaction ()

Static Public Member Functions

static QString defaultSearchField ()
static Soprano::Node getResource (lucene::document::Document *document)

Detailed Description

The CLuceneIndex provides a wrapper around a CLucene index which stores RDF statements.

It is used by the IndexFilterModel to actually handle the index. It has been made visible in the public API to provide the possibility for advanced queries and data modifications.

CLuceneIndex is thread-safe.

Data organization

In the Soprano index each resouce gets its own clucene document. Only statements with literal objects are indexed. The clucene is identified through the statements' subject and then a new field is created that uses the statement's predicate as field name and the statement's object as value. The index ignores all context information.

Warning:
The API is subject to change. Most likely CLucene classes will be wrapped and hidden from the public API.
Author:
Sebastian Trueg <trueg@kde.org>

Definition at line 75 of file cluceneindex.h.


Constructor & Destructor Documentation

Soprano::Index::CLuceneIndex::CLuceneIndex ( lucene::analysis::Analyzer *  analyzer = 0  ) 
Parameters:
analyzer The analyzer to be used. If 0 a standard analyzer will be created.
Soprano::Index::CLuceneIndex::~CLuceneIndex (  ) 

Destructor.

Calls close().


Member Function Documentation

Error::ErrorCode Soprano::Index::CLuceneIndex::addStatement ( const Soprano::Statement &   ) 

Indexes a statement.

Returns:
An error code or 0 on success
void Soprano::Index::CLuceneIndex::clear (  ) 

Clear the index, i.e.

delete all entries.

Since:
2.1
void Soprano::Index::CLuceneIndex::close (  ) 

Close the index.

Write back any changes, close any open transactions. (Is called in ~CLuceneIndex())

bool Soprano::Index::CLuceneIndex::closeTransaction ( int  id  ) 

Close a transaction and write the changes back to the index.

Parameters:
id The transaction ID as returned by startTransaction()
Returns:
true if the transaction was closed, false if no transaction was started, a wrong transaction id has been supplied, or a clucene error occured.
static QString Soprano::Index::CLuceneIndex::defaultSearchField (  )  [static]

This is a temporary method which supports the advanced query interface based on CLucene classes.

The Soprano index creates one special field for each indexed resource which contains all data to allow simple queries without property names or URIs.

Returns:
The name of the default CLucene search field to be queried when no properties are known.
lucene::document::Document* Soprano::Index::CLuceneIndex::documentForResource ( const Node &  resource  ) 

Get a document for a specific resource.

This is only possible after starting a transaction.

Parameters:
resource The resource for which a document is requested.
Returns:
The document representing the resource or 0 if no transaction has been started or a clucene error occured.
Warning:
This is an advanced method. Calling this method is thread-safe but using the returned document is not.
void Soprano::Index::CLuceneIndex::dump ( QTextStream &   )  const

Dump the index contents to the stream.

static Soprano::Node Soprano::Index::CLuceneIndex::getResource ( lucene::document::Document *  document  )  [static]

Returns the Resource corresponding with the specified Document.

bool Soprano::Index::CLuceneIndex::isOpen (  )  const
Returns:
true If the index has been opened successfully.
See also:
open()
bool Soprano::Index::CLuceneIndex::open ( const QString &  folder,
bool  force = false 
)

Open the index.

Parameters:
folder The folder where the index is stored.
force If true any CLucene locks on the folder are removed. This is useful if a previous session crashed and left an unused lock lying around.
void Soprano::Index::CLuceneIndex::optimize (  ) 

Optimize the index for search.

This makes sense after adding or removing a large number of statements.

Since:
2.2
lucene::analysis::Analyzer* Soprano::Index::CLuceneIndex::queryAnalyzer (  )  const

Get the query analyzer set in setQueryAnalyzer.

This method is only provided for convenience.

Returns:
The analyzer set in setQueryAnalyzer or 0 if none was set.
Since:
2.3
Error::ErrorCode Soprano::Index::CLuceneIndex::removeStatement ( const Soprano::Statement &   ) 

Removes a statement from the index.

Returns:
An error code or 0 on success
int Soprano::Index::CLuceneIndex::resourceCount (  )  const

Get the number of indexed resources.

Returns:
The number of indexed resoruces or -1 on error (In the case of error lastError() provides more information.
Iterator<QueryHit> Soprano::Index::CLuceneIndex::search ( lucene::search::Query *  query  ) 

Evaluates the given query.

Each hit is a resource and a score. Resource properties may be read from the model.

Parameters:
query The query to evaluate. The iterator takes ownership of the query. Do not delete.it! (If anyone using this understands the weird CLucene memory management enough to fix this issue, please...)
Returns:
The results as an iterator over QueryHit objects or an invalid iterator on error.
Warning:
The result iterator uses the query object.
Iterator<QueryHit> Soprano::Index::CLuceneIndex::search ( const QString &  query  ) 

Evaluates the given query.

Each hit is a resource and a score. Resource properties may be read from the model.

Parameters:
query The query in the CLucene query language.
Returns:
The results as an iterator over QueryHit objects or an invalid iterator on error.
void Soprano::Index::CLuceneIndex::setQueryAnalyzer ( lucene::analysis::Analyzer *  analyzer  ) 

Optionally set the analyzer to be used for query parsing.

By default the index analyzer specified in the constructor is used.

CLuceneIndex will not take ownership of the analyzer.

See also:
search(const QString&)
Since:
2.3
int Soprano::Index::CLuceneIndex::startTransaction (  ) 

Start a new transaction.

After calling this method multiple fields and statements may be added to the index and nothing is written back to disk. A transaction has to be closed. Otherwise the data will not be written to the index. (All transactions are closed on deletion.)

Methods such as addStatement will start and close a transaction internally if none has been started before.

Returns:
A transaction id that has to be used to close the transaction. This is a safety mechanism to ensure that no other user closes one's transaction. If another transaction has already been started 0 is returned.

The documentation for this class was generated from the following file:
  • cluceneindex.h

soprano

Skip menu "soprano"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE Support

Skip menu "KDE Support"
  • akonadi
  • Decibel
  • grantlee
  • kdewin
  • phonon
  •     Backend
  • polkit-qt
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for KDE Support by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal