Class LuceneQueryFactory
- java.lang.Object
-
- org.apache.jackrabbit.core.query.lucene.LuceneQueryFactory
-
public class LuceneQueryFactory extends Object
Factory that creates Lucene queries from QOM elements.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classLuceneQueryFactory.QueryPairprotected static classLuceneQueryFactory.Transform
-
Field Summary
Fields Modifier and Type Field Description protected OperandEvaluatorevaluatorOperand evaluatorprotected SearchIndexindexLucene search indexprotected StringmixinTypesFieldprotected NamePathResolvernpResolverNamePathResolver to map namespace mappings to internal prefixesprotected NamespaceMappingsnsMappingsNamespace mappings to internal prefixesprotected NodeTypeManagerntManagerNode type managerprotected StringprimaryTypeFieldprotected SessionImplsessionSession of the user executing this query
-
Constructor Summary
Constructors Constructor Description LuceneQueryFactory(SessionImpl session, SearchIndex index, Map<String,Value> bindVariables)Creates a new lucene query factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddBooleanConstraint(BooleanQuery query, Constraint constraint, BooleanClause.Occur occur, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher)protected Querycreate(Constraint constraint, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher)Querycreate(Selector selector)Creates a lucene query for the given QOM selector.Querycreate(FullTextSearchImpl fts)Creates a lucene query for the given QOM full text search.Querycreate(PropertyExistenceImpl prop)Creates a lucene query for the given QOM property existence constraint.protected TermcreateNodeTypeTerm(NodeType type)List<Row>execute(Map<String,PropertyValue> columns, Selector selector, Constraint constraint, Sort sort, boolean externalSort, long offsetIn, long limitIn)protected BooleanQuerygetAndQuery(And and, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher)protected QuerygetComparisonQuery(DynamicOperand left, int transform, String operator, StaticOperand rigth, Map<String,NodeType> selectorMap)protected QuerygetDescendantNodeQuery(DescendantNode dn, JackrabbitIndexSearcher searcher)protected QuerygetFullTextSearchQuery(FullTextSearch fts)protected QuerygetNodeIdQuery(String field, String path)protected QuerygetNodeLocalNameQuery(int transform, String operator, StaticOperand right)protected QuerygetNodeNameQuery(int transform, String operator, StaticOperand right)protected org.apache.jackrabbit.core.query.lucene.NotQuerygetNotQuery(Not not, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher)protected BooleanQuerygetOrQuery(Or or, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher)protected QuerygetPropertyExistenceQuery(PropertyExistence property)protected QuerygetPropertyValueQuery(String field, String operator, Value value, int type, int transform)protected TermgetTerm(String field, String value)protected StringgetValueString(Value value, int type)protected PredicatemapConstraintToQueryAndFilter(LuceneQueryFactory.QueryPair query, Constraint constraint, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher, IndexReader reader)
-
-
-
Field Detail
-
session
protected final SessionImpl session
Session of the user executing this query
-
ntManager
protected final NodeTypeManager ntManager
Node type manager
-
index
protected final SearchIndex index
Lucene search index
-
nsMappings
protected final NamespaceMappings nsMappings
Namespace mappings to internal prefixes
-
npResolver
protected final NamePathResolver npResolver
NamePathResolver to map namespace mappings to internal prefixes
-
evaluator
protected final OperandEvaluator evaluator
Operand evaluator
-
mixinTypesField
protected final String mixinTypesField
-
primaryTypeField
protected final String primaryTypeField
-
-
Constructor Detail
-
LuceneQueryFactory
public LuceneQueryFactory(SessionImpl session, SearchIndex index, Map<String,Value> bindVariables) throws RepositoryException
Creates a new lucene query factory.- Parameters:
session- the session that executes the query.index- the search indexbindVariables- the bind variable values of the query- Throws:
RepositoryException
-
-
Method Detail
-
execute
public List<Row> execute(Map<String,PropertyValue> columns, Selector selector, Constraint constraint, Sort sort, boolean externalSort, long offsetIn, long limitIn) throws RepositoryException, IOException
- Parameters:
columns-selector-constraint-externalSort- iftrueit means that the lqf should just let the QueryEngine take care of sorting and applying applying offset and limit constraintsoffsetIn- used in paginationlimitIn- used in pagination- Returns:
- a list of rows
- Throws:
RepositoryExceptionIOException
-
create
public Query create(Selector selector) throws RepositoryException
Creates a lucene query for the given QOM selector.- Parameters:
selector- the selector.- Returns:
- a lucene query for the given selector.
- Throws:
RepositoryException- if an error occurs while creating the query.
-
createNodeTypeTerm
protected Term createNodeTypeTerm(NodeType type) throws RepositoryException
- Throws:
RepositoryException
-
create
public Query create(FullTextSearchImpl fts) throws RepositoryException
Creates a lucene query for the given QOM full text search.- Parameters:
fts- the full text search constraint.- Returns:
- the lucene query for the given constraint.
- Throws:
RepositoryException- if an error occurs while creating the query.
-
create
public Query create(PropertyExistenceImpl prop) throws RepositoryException
Creates a lucene query for the given QOM property existence constraint.- Parameters:
prop- the QOM constraint.- Returns:
- the lucene query for the given constraint.
- Throws:
RepositoryException- if an error occurs while creating the query.
-
mapConstraintToQueryAndFilter
protected Predicate mapConstraintToQueryAndFilter(LuceneQueryFactory.QueryPair query, Constraint constraint, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher, IndexReader reader) throws RepositoryException, IOException
- Throws:
RepositoryExceptionIOException
-
create
protected Query create(Constraint constraint, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException
- Throws:
RepositoryExceptionIOException
-
getDescendantNodeQuery
protected Query getDescendantNodeQuery(DescendantNode dn, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException
- Throws:
RepositoryExceptionIOException
-
getFullTextSearchQuery
protected Query getFullTextSearchQuery(FullTextSearch fts) throws RepositoryException
- Throws:
RepositoryException
-
getAndQuery
protected BooleanQuery getAndQuery(And and, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException
- Throws:
RepositoryExceptionIOException
-
getOrQuery
protected BooleanQuery getOrQuery(Or or, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException
- Throws:
RepositoryExceptionIOException
-
addBooleanConstraint
protected void addBooleanConstraint(BooleanQuery query, Constraint constraint, BooleanClause.Occur occur, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException
- Throws:
RepositoryExceptionIOException
-
getNotQuery
protected org.apache.jackrabbit.core.query.lucene.NotQuery getNotQuery(Not not, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException
- Throws:
RepositoryExceptionIOException
-
getPropertyExistenceQuery
protected Query getPropertyExistenceQuery(PropertyExistence property) throws RepositoryException
- Throws:
RepositoryException
-
getComparisonQuery
protected Query getComparisonQuery(DynamicOperand left, int transform, String operator, StaticOperand rigth, Map<String,NodeType> selectorMap) throws RepositoryException
- Throws:
RepositoryException
-
getNodeNameQuery
protected Query getNodeNameQuery(int transform, String operator, StaticOperand right) throws RepositoryException
- Throws:
RepositoryException
-
getNodeLocalNameQuery
protected Query getNodeLocalNameQuery(int transform, String operator, StaticOperand right) throws RepositoryException
- Throws:
RepositoryException
-
getNodeIdQuery
protected Query getNodeIdQuery(String field, String path) throws RepositoryException
- Throws:
RepositoryException
-
getPropertyValueQuery
protected Query getPropertyValueQuery(String field, String operator, Value value, int type, int transform) throws RepositoryException
- Throws:
RepositoryException
-
getValueString
protected String getValueString(Value value, int type) throws RepositoryException
- Throws:
RepositoryException
-
-