|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.hp.hpl.jena.util.ModelIndex
Utility that provides a simple wrapper onto a Lucene text index for performing searches across a Model or MultiModel.
Simple literal-valued properties are indexed as text strings.
Properties pointing to resources are handled in several ways. If the resource is a bNode the literal-valued properties of that bNode can be optionally added as index values for the root resource. Resources that appear in an optional ontology will be indexed using label terms for the class/concept in the ontology (uses rdfs:label and skos labels). Otherwise the localName of the resource is used as the index.
The fields used for properties can either be full URI's or just the localName part (to ease interactive construction of Lucene query strings).
| Nested Class Summary | |
static class |
ModelIndex.SearchResults
Inner class used to return the results from a free text search. |
| Field Summary | |
static java.lang.String |
ALL_FIELD
The field name for all index terms |
static java.lang.String |
URI_FIELD
The field name for the base URI |
| Constructor Summary | |
ModelIndex(java.lang.String path,
com.hp.hpl.jena.rdf.model.Model data,
com.hp.hpl.jena.rdf.model.Model ontology)
Constructor. |
|
| Method Summary | |
protected void |
addBnodeClosure(com.hp.hpl.jena.rdf.model.Resource base,
java.lang.StringBuffer value,
java.util.Set found)
Add all literal values fo the given bNode to the index string |
protected void |
addLabelStrings(com.hp.hpl.jena.rdf.model.Property p,
com.hp.hpl.jena.rdf.model.Resource base,
java.lang.StringBuffer value)
Add to the current index string all literal values of the given property in the ontology. |
void |
addModelIndex(com.hp.hpl.jena.rdf.model.Model newData)
Add a new set of data to the index. |
protected void |
doIndex(com.hp.hpl.jena.rdf.model.Model newData,
org.apache.lucene.index.IndexWriter indexWriter)
Index all the subject nodes in the given RDF model. |
protected org.apache.lucene.analysis.Analyzer |
getAnalyzer()
Return the default analyzer to use for string tokenizing. |
protected static com.hp.hpl.jena.rdf.model.Resource |
getResourceFor(java.lang.String label,
com.hp.hpl.jena.rdf.model.Model data)
Return a resource from its uri/bnode label |
protected static java.lang.String |
getUriFor(com.hp.hpl.jena.rdf.model.Resource r)
Return a uri/bnode label for a resource |
void |
index()
Rebuild the entire index against the given RDF data, previous index information will be lost. |
java.lang.Object |
isQueryWellformed(java.lang.String query)
Check a query string is legal. |
static void |
main(java.lang.String[] args)
Temporary development only. |
ModelIndex.SearchResults |
search(java.lang.String query)
Search the index. |
void |
setIndexBnodeClosure(boolean bnodeClosure)
Set how bNode values are indexed |
void |
setIndexByLocalName(boolean localName)
Set how property names are mapped to searchable fields. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String URI_FIELD
public static final java.lang.String ALL_FIELD
| Constructor Detail |
public ModelIndex(java.lang.String path,
com.hp.hpl.jena.rdf.model.Model data,
com.hp.hpl.jena.rdf.model.Model ontology)
path - the file path to where the index is storeddata - the data to be searched (which may be
a MultiModel or other union as well as a simple model)ontology - an optional Model containing any class/concept information,
ObjectProperties pointing to resources in the ontology will be indexed by label.| Method Detail |
public void index()
throws java.io.IOException
java.io.IOException
public void addModelIndex(com.hp.hpl.jena.rdf.model.Model newData)
throws java.io.IOException
java.io.IOExceptionpublic void setIndexByLocalName(boolean localName)
localName - if true then only the localName part of the property
name is used used as the field name.public void setIndexBnodeClosure(boolean bnodeClosure)
bnodeClosure - if true then the label of a bNode is taken to
be the union of all property values of the bNode (including recursive bNodes)
public ModelIndex.SearchResults search(java.lang.String query)
throws com.hp.hpl.jena.shared.JenaException
query - a lucene query string (which thus supports fielded searches and
boolean searches as well as standard free text)
com.hp.hpl.jena.shared.JenaExceptionpublic java.lang.Object isQueryWellformed(java.lang.String query)
protected void doIndex(com.hp.hpl.jena.rdf.model.Model newData,
org.apache.lucene.index.IndexWriter indexWriter)
throws java.io.IOException
java.io.IOException
protected void addLabelStrings(com.hp.hpl.jena.rdf.model.Property p,
com.hp.hpl.jena.rdf.model.Resource base,
java.lang.StringBuffer value)
protected void addBnodeClosure(com.hp.hpl.jena.rdf.model.Resource base,
java.lang.StringBuffer value,
java.util.Set found)
protected org.apache.lucene.analysis.Analyzer getAnalyzer()
protected static java.lang.String getUriFor(com.hp.hpl.jena.rdf.model.Resource r)
protected static com.hp.hpl.jena.rdf.model.Resource getResourceFor(java.lang.String label,
com.hp.hpl.jena.rdf.model.Model data)
public static void main(java.lang.String[] args)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||