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 class
LuceneQueryFactory.QueryPair
protected static class
LuceneQueryFactory.Transform
-
Field Summary
Fields Modifier and Type Field Description protected OperandEvaluator
evaluator
Operand evaluatorprotected SearchIndex
index
Lucene search indexprotected String
mixinTypesField
protected NamePathResolver
npResolver
NamePathResolver to map namespace mappings to internal prefixesprotected NamespaceMappings
nsMappings
Namespace mappings to internal prefixesprotected NodeTypeManager
ntManager
Node type managerprotected String
primaryTypeField
protected SessionImpl
session
Session 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 void
addBooleanConstraint(BooleanQuery query, Constraint constraint, BooleanClause.Occur occur, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher)
protected Query
create(Constraint constraint, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher)
Query
create(Selector selector)
Creates a lucene query for the given QOM selector.Query
create(FullTextSearchImpl fts)
Creates a lucene query for the given QOM full text search.Query
create(PropertyExistenceImpl prop)
Creates a lucene query for the given QOM property existence constraint.protected Term
createNodeTypeTerm(NodeType type)
List<Row>
execute(Map<String,PropertyValue> columns, Selector selector, Constraint constraint, Sort sort, boolean externalSort, long offsetIn, long limitIn)
protected BooleanQuery
getAndQuery(And and, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher)
protected Query
getComparisonQuery(DynamicOperand left, int transform, String operator, StaticOperand rigth, Map<String,NodeType> selectorMap)
protected Query
getDescendantNodeQuery(DescendantNode dn, JackrabbitIndexSearcher searcher)
protected Query
getFullTextSearchQuery(FullTextSearch fts)
protected Query
getNodeIdQuery(String field, String path)
protected Query
getNodeLocalNameQuery(int transform, String operator, StaticOperand right)
protected Query
getNodeNameQuery(int transform, String operator, StaticOperand right)
protected org.apache.jackrabbit.core.query.lucene.NotQuery
getNotQuery(Not not, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher)
protected BooleanQuery
getOrQuery(Or or, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher)
protected Query
getPropertyExistenceQuery(PropertyExistence property)
protected Query
getPropertyValueQuery(String field, String operator, Value value, int type, int transform)
protected Term
getTerm(String field, String value)
protected String
getValueString(Value value, int type)
protected Predicate
mapConstraintToQueryAndFilter(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
- iftrue
it 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:
RepositoryException
IOException
-
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:
RepositoryException
IOException
-
create
protected Query create(Constraint constraint, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException
- Throws:
RepositoryException
IOException
-
getDescendantNodeQuery
protected Query getDescendantNodeQuery(DescendantNode dn, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException
- Throws:
RepositoryException
IOException
-
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:
RepositoryException
IOException
-
getOrQuery
protected BooleanQuery getOrQuery(Or or, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException
- Throws:
RepositoryException
IOException
-
addBooleanConstraint
protected void addBooleanConstraint(BooleanQuery query, Constraint constraint, BooleanClause.Occur occur, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException
- Throws:
RepositoryException
IOException
-
getNotQuery
protected org.apache.jackrabbit.core.query.lucene.NotQuery getNotQuery(Not not, Map<String,NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException
- Throws:
RepositoryException
IOException
-
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
-
-