Package org.eclipse.rdf4j.sail.lucene
Class QuerySpecBuilder
- java.lang.Object
-
- org.eclipse.rdf4j.sail.lucene.QuerySpecBuilder
-
- All Implemented Interfaces:
SearchQueryInterpreter
public class QuerySpecBuilder extends java.lang.Object implements SearchQueryInterpreter
A QueryInterpreter creates a set of QuerySpecs based on Lucene-related StatementPatterns that it finds in a TupleExpr.QuerySpecs will only be created when the set of StatementPatterns is complete (i.e. contains at least a matches and a query statement connected properly) and correct (query pattern has a literal object, matches a resource subject, etc.).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
QuerySpecBuilder.PatternFilter
-
Field Summary
Fields Modifier and Type Field Description private boolean
incompleteQueryFails
private IRI
indexId
private static org.slf4j.Logger
logger
-
Constructor Summary
Constructors Constructor Description QuerySpecBuilder(boolean incompleteQueryFails)
Initialize a new QuerySpecBuilderQuerySpecBuilder(boolean incompleteQueryFails, IRI indexId)
Initialize a new QuerySpecBuilder
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private void
failOrWarn(java.lang.Exception exception)
private void
failOrWarn(java.lang.String message)
private StatementPattern
getPattern(Var subjectVar, java.util.ArrayList<StatementPattern> patterns)
Returns the StatementPattern, if any, from the specified Collection that has the specified subject var.private java.util.List<StatementPattern>
getQueryVar(Var subjectVar, java.util.ArrayList<StatementPattern> patterns)
Return all the var of the patterns with the subject subjectVar, if a pattern is a literal, it will return a singleton list, otherwise it will return an empty list or a list without any literal varjava.util.Set<QuerySpec>
process(TupleExpr tupleExpr, BindingSet bindings)
Deprecated.void
process(TupleExpr tupleExpr, BindingSet bindings, java.util.Collection<SearchQueryEvaluator> result)
Appends a set of QuerySpecs embodying all necessary information to perform the Lucene query embedded in a TupleExpr.
-
-
-
Field Detail
-
logger
private static final org.slf4j.Logger logger
-
incompleteQueryFails
private final boolean incompleteQueryFails
-
indexId
private final IRI indexId
-
-
Constructor Detail
-
QuerySpecBuilder
public QuerySpecBuilder(boolean incompleteQueryFails)
Initialize a new QuerySpecBuilder- Parameters:
incompleteQueryFails
- seeLuceneSail.isIncompleteQueryFails()
-
QuerySpecBuilder
public QuerySpecBuilder(boolean incompleteQueryFails, IRI indexId)
Initialize a new QuerySpecBuilder- Parameters:
incompleteQueryFails
- seeLuceneSail.isIncompleteQueryFails()
indexId
- the id of the index, null to do not filter by index id, seeLuceneSail.INDEX_ID
-
-
Method Detail
-
process
@Deprecated public java.util.Set<QuerySpec> process(TupleExpr tupleExpr, BindingSet bindings) throws SailException
Deprecated.Returns a set of QuerySpecs embodying all necessary information to perform the Lucene query embedded in a TupleExpr. To be removed, prefer#process(TupleExpr, BindingSet, Collection
.) - Throws:
SailException
-
process
public void process(TupleExpr tupleExpr, BindingSet bindings, java.util.Collection<SearchQueryEvaluator> result) throws SailException
Appends a set of QuerySpecs embodying all necessary information to perform the Lucene query embedded in a TupleExpr.- Specified by:
process
in interfaceSearchQueryInterpreter
- Parameters:
tupleExpr
- the TupleExpr to process.bindings
- any bindings.result
- the Collection to add any SearchQueryEvaluators to.- Throws:
SailException
-
failOrWarn
private void failOrWarn(java.lang.Exception exception) throws SailException
- Throws:
SailException
-
failOrWarn
private void failOrWarn(java.lang.String message) throws SailException
- Throws:
SailException
-
getPattern
private StatementPattern getPattern(Var subjectVar, java.util.ArrayList<StatementPattern> patterns) throws java.lang.IllegalArgumentException
Returns the StatementPattern, if any, from the specified Collection that has the specified subject var. If multiple StatementPatterns exist with this subject var, an IllegalArgumentException is thrown. It also removes the patter from the arraylist, to be able to check if some patterns are added without a MATCHES property.- Throws:
java.lang.IllegalArgumentException
-
getQueryVar
private java.util.List<StatementPattern> getQueryVar(Var subjectVar, java.util.ArrayList<StatementPattern> patterns) throws java.lang.IllegalArgumentException
Return all the var of the patterns with the subject subjectVar, if a pattern is a literal, it will return a singleton list, otherwise it will return an empty list or a list without any literal var- Throws:
java.lang.IllegalArgumentException
-
-