Class AbstractSearchIndex
java.lang.Object
org.eclipse.rdf4j.sail.lucene.AbstractSearchIndex
- All Implemented Interfaces:
SearchIndex
- Direct Known Subclasses:
AbstractLuceneIndex
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.slf4j.Loggerprotected intprivate final ValueFactory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the provided literal is accepted by the LuceneIndex to be indexed.protected abstract voidfinal voidaddDocuments(Resource subject, List<Statement> statements) Add a complete Lucene Document based on these statements.private voidaddProperty(String field, String value, SearchDocument document) private voidaddProperty(Statement statement, SearchDocument document) check if the passed statement should be added (is it indexed? is it stored?) and add it as predicate to the passed document.final voidaddRemoveStatements(Collection<Statement> added, Collection<Statement> removed) Add many statements at the same time, remove many statements at the same time.final voidaddStatement(Statement statement) Indexes the specified Statement.protected abstract SearchDocumentprivate booleancopyDocument(SearchDocument newDocument, SearchDocument document, Map<String, Set<String>> removedProperties) Creates a copy of the old document; updating the retrieved Document instance works ok for stored properties but indexed data gets lost when doing an IndexWriter.updateDocument with it.private static intcountPropertyValues(SearchDocument document) protected abstract voidfinal Collection<BindingSet> evaluate(SearchQueryEvaluator evaluator) private Iterable<? extends DocumentDistance> evaluateQuery(DistanceQuerySpec query) private Iterable<? extends DocumentResult> private Iterable<? extends DocumentScore> evaluateQuery(QuerySpec query) Evaluates one Lucene Query.private BindingSetCollectiongenerateBindingSets(DistanceQuerySpec query, Iterable<? extends DocumentDistance> hits) private BindingSetCollectiongenerateBindingSets(GeoRelationQuerySpec query, Iterable<? extends DocumentResult> hits) private BindingSetCollectiongenerateBindingSets(QuerySpec query, Iterable<? extends DocumentScore> hits) This method generates bindings from the given result of a Lucene query.protected abstract Iterable<? extends DocumentDistance> geoQuery(IRI geoProperty, org.locationtech.spatial4j.shape.Point p, IRI units, double distance, String distanceVar, Var context) protected abstract Iterable<? extends DocumentResult> geoRelationQuery(String relation, IRI geoProperty, String wkt, Var context) protected abstract SearchDocumentgetDocument(String id) protected abstract Iterable<? extends SearchDocument> getDocuments(String resourceId) protected ResourcegetResource(SearchDocument document) Returns the Resource corresponding with the specified Document.protected abstract org.locationtech.spatial4j.context.SpatialContextgetSpatialContext(String property) private static StringgetUnitSymbol(IRI units) voidinitialize(Properties parameters) booleanisGeoField(String fieldName) Returns true if the given property contains a geometry.booleanisIndexedTypeStatement(Statement statement) Returns true if the given statement is a type statement of the right type, seeLuceneSail.INDEXEDTYPESto use.booleanis theLuceneSail.INDEXEDTYPESparameter set for this index.booleanisTypeStatement(Statement statement) Returns true if the given statement is a type statement, seeLuceneSail.INDEXEDTYPESto use.protected abstract BulkUpdaterprotected abstract SearchDocumentnewDocument(String id, String resourceId, String context) protected ObjectparseLuceneQueryShape(String property, String value) protected org.locationtech.spatial4j.shape.ShapeparseQueryPoint(String property, String value) protected org.locationtech.spatial4j.shape.ShapeparseQueryShape(String property, String value) protected abstract Iterable<? extends DocumentScore> final voidremoveStatement(Statement statement) Removes the specified Statement from the indexes.This should be called from within a begin-commit-rollbackprotected abstract voidMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SearchIndex
begin, clear, clearContexts, commit, rollback, shutDown
-
Field Details
-
logger
private final org.slf4j.Logger logger -
vf
-
REJECTED_DATATYPES
-
maxDocs
protected int maxDocs -
wktFields
-
indexedLangs
-
indexedTypeMapping
-
-
Constructor Details
-
AbstractSearchIndex
public AbstractSearchIndex()
-
-
Method Details
-
initialize
- Specified by:
initializein interfaceSearchIndex- Throws:
Exception
-
getSpatialContext
protected abstract org.locationtech.spatial4j.context.SpatialContext getSpatialContext(String property) -
accept
Returns whether the provided literal is accepted by the LuceneIndex to be indexed. It for instance does not make much since to index xsd:float.- Specified by:
acceptin interfaceSearchIndex- Parameters:
literal- the literal to be accepted- Returns:
- true if the given literal will be indexed by this LuceneIndex
-
isGeoField
Description copied from interface:SearchIndexReturns true if the given property contains a geometry.- Specified by:
isGeoFieldin interfaceSearchIndex- Parameters:
fieldName-- Returns:
- boolean
-
isTypeStatement
Description copied from interface:SearchIndexReturns true if the given statement is a type statement, seeLuceneSail.INDEXEDTYPESto use. This method should return false ifSearchIndex.isTypeFilteringEnabled()returns false.- Specified by:
isTypeStatementin interfaceSearchIndex- Parameters:
statement- statement- Returns:
- boolean
-
isTypeFilteringEnabled
public boolean isTypeFilteringEnabled()Description copied from interface:SearchIndexis theLuceneSail.INDEXEDTYPESparameter set for this index.- Specified by:
isTypeFilteringEnabledin interfaceSearchIndex- Returns:
- boolean
-
isIndexedTypeStatement
Description copied from interface:SearchIndexReturns true if the given statement is a type statement of the right type, seeLuceneSail.INDEXEDTYPESto use. This method should return false ifSearchIndex.isTypeFilteringEnabled()returns false.- Specified by:
isIndexedTypeStatementin interfaceSearchIndex- Parameters:
statement- statement- Returns:
- boolean
-
getIndexedTypeMapping
- Specified by:
getIndexedTypeMappingin interfaceSearchIndex- Returns:
- the accepted types for a particular predicate map (predicate -> [objects])
-
addStatement
Indexes the specified Statement.- Specified by:
addStatementin interfaceSearchIndex- Parameters:
statement-- Throws:
IOException
-
removeStatement
Description copied from interface:SearchIndexRemoves the specified Statement from the indexes.This should be called from within a begin-commit-rollbackblock.
- Specified by:
removeStatementin interfaceSearchIndex- Parameters:
statement-- Throws:
IOException
-
addRemoveStatements
public final void addRemoveStatements(Collection<Statement> added, Collection<Statement> removed) throws IOException Add many statements at the same time, remove many statements at the same time. Ordering by resource has to be done inside this method. The passed added/removed sets are disjunct, no statement can be in both- Specified by:
addRemoveStatementsin interfaceSearchIndex- Parameters:
added- all added statements, can have multiple subjectsremoved- all removed statements, can have multiple subjects- Throws:
IOException
-
copyDocument
private boolean copyDocument(SearchDocument newDocument, SearchDocument document, Map<String, Set<String>> removedProperties) Creates a copy of the old document; updating the retrieved Document instance works ok for stored properties but indexed data gets lost when doing an IndexWriter.updateDocument with it. -
countPropertyValues
-
addDocuments
Add a complete Lucene Document based on these statements. Do not search for an existing document with the same subject id. (assume the existing document was deleted)- Specified by:
addDocumentsin interfaceSearchIndex- Parameters:
subject-statements- the statements that make up the resource- Throws:
IOException
-
addProperty
check if the passed statement should be added (is it indexed? is it stored?) and add it as predicate to the passed document. No checks whether the predicate was already there.- Parameters:
statement- the statement to adddocument- the document to add to
-
addProperty
-
evaluate
- Specified by:
evaluatein interfaceSearchIndex- Throws:
SailException
-
evaluateQuery
Evaluates one Lucene Query. It distinguishes between two cases, the one where no subject is given and the one were it is given.- Parameters:
query- the Lucene query to evaluate- Returns:
- QueryResult consisting of hits and highlighter
-
generateBindingSets
private BindingSetCollection generateBindingSets(QuerySpec query, Iterable<? extends DocumentScore> hits) throws SailException This method generates bindings from the given result of a Lucene query.- Parameters:
query- the Lucene query- Returns:
- a LinkedHashSet containing generated bindings
- Throws:
SailException
-
evaluateQuery
-
getUnitSymbol
-
generateBindingSets
private BindingSetCollection generateBindingSets(DistanceQuerySpec query, Iterable<? extends DocumentDistance> hits) throws SailException - Throws:
SailException
-
evaluateQuery
-
generateBindingSets
private BindingSetCollection generateBindingSets(GeoRelationQuerySpec query, Iterable<? extends DocumentResult> hits) throws SailException - Throws:
SailException
-
parseLuceneQueryShape
protected Object parseLuceneQueryShape(String property, String value) throws ParseException, IOException - Throws:
ParseExceptionIOException
-
parseQueryShape
protected org.locationtech.spatial4j.shape.Shape parseQueryShape(String property, String value) throws ParseException - Throws:
ParseException
-
parseQueryPoint
protected org.locationtech.spatial4j.shape.Shape parseQueryPoint(String property, String value) throws ParseException - Throws:
ParseException
-
getResource
Returns the Resource corresponding with the specified Document. -
getDocument
- Throws:
IOException
-
getDocuments
protected abstract Iterable<? extends SearchDocument> getDocuments(String resourceId) throws IOException - Throws:
IOException
-
newDocument
-
copyDocument
-
addDocument
- Throws:
IOException
-
updateDocument
- Throws:
IOException
-
deleteDocument
- Throws:
IOException
-
query
protected abstract Iterable<? extends DocumentScore> query(Resource subject, QuerySpec param) throws MalformedQueryException, IOException - Throws:
MalformedQueryExceptionIOException
-
geoQuery
protected abstract Iterable<? extends DocumentDistance> geoQuery(IRI geoProperty, org.locationtech.spatial4j.shape.Point p, IRI units, double distance, String distanceVar, Var context) throws MalformedQueryException, IOException - Throws:
MalformedQueryExceptionIOException
-
geoRelationQuery
protected abstract Iterable<? extends DocumentResult> geoRelationQuery(String relation, IRI geoProperty, String wkt, Var context) throws MalformedQueryException, IOException - Throws:
MalformedQueryExceptionIOException
-
newBulkUpdate
-