You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

LuceneContext is a Context wrapper that maintains a full-text index on any metadata that is written to it, using Lucene as the full-text indexing engine.

Note that LuceneContext will not index text that is already in the wrapped Context, instead only indexing text when new metadata is written to the LuceneContext.

LuceneContext works by creating a full text index for all literal objects, which may be searched using TripleMatcher.

Setting it up

This context requires two bits of information for the configuration.

  1. A context for its triples
  2. A directory for the Lucene index

Lucene, of course, has no concept of what a triple is nor does it know anything about RDF, hence a backing context is used to store the triples is needed.

Lucene also needs a directory for its indices. This will be need to be initialized before use. So, before the very first use of the context, clients will need to call the initialize method. Warning: This will remove any existing index! If you do not need to initialize (or re-initialize) the index, do not call this method.

Usage

You can write metadata and data to LuceneContext as with most other Context implementations; the operations are forwarded to the TripleContext. For TripleMatcher, patterns are allowed that contain Lucene-specific query syntax. For example:

TripleMatcher tm = new TripleMatcher();
tm.setObject(Resource.literal("comment*"));
luceneContext.perform(tm);
//... etc.



  • No labels