Package com.day.cq.search.eval
Class PredicateGroupEvaluator
- java.lang.Object
-
- com.day.cq.search.eval.AbstractPredicateEvaluator
-
- com.day.cq.search.eval.PredicateGroupEvaluator
-
- All Implemented Interfaces:
PredicateEvaluator
- Direct Known Subclasses:
SavedQueryPredicate
public class PredicateGroupEvaluator extends AbstractPredicateEvaluator
Allows to build nested conditions. Groups can contain nested groups. Everything in a querybuilder query is implicitly in a root group, which can havep.or
andp.not
as well.Example for matching either one of two properties against a value:
group.p.or=true group.1_property=jcr:title group.1_property.value=My Page group.2_property=navTitle group.2_property.value=My Page
This is conceptually(1_property OR 2_property)
.Example for nested groups:
fulltext=Management group.p.or=true group.1_group.path=/content/geometrixx/en group.1_group.type=cq:Page group.2_group.path=/content/dam/geometrixx group.2_group.type=dam:Asset
This searches for the term "Management" within pages in /content/geometrixx/en or in assets in /content/dam/geometrixx. This is conceptuallyfulltext AND ( (path AND type) OR (path AND type) )
. Be aware that such OR joins need good indexes for performance.Name:
groupProperties:
- p.or
- if set to "true", only one predicate in the group must match (defaults to "false", meaning all must match)
- p.not
- if set to "true", negates the group (defaults to "false")
- <predicate>
- add nested predicates
- N_<predicate>
- add multiple nested predicates of the same time, e.g. 1_property, 2_property, ...
- Since:
- 5.2
-
-
Constructor Summary
Constructors Constructor Description PredicateGroupEvaluator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canFilter(Predicate predicate, EvaluationContext context)
Returns the same as the deprecatedAbstractPredicateEvaluator.isFiltering(Predicate, EvaluationContext)
method (ie.boolean
canXpath(Predicate predicate, EvaluationContext context)
Returns the inverted boolean value of the deprecatedAbstractPredicateEvaluator.isFiltering(Predicate, EvaluationContext)
method (ie.FacetExtractor
getFacetExtractor(Predicate predicate, EvaluationContext context)
Default implementation that always returnsnull
, ie.java.lang.String
getXPathExpression(Predicate p, EvaluationContext context)
Default implementation that always returnsnull
, ie.boolean
includes(Predicate p, Row row, EvaluationContext context)
Default implementation that always returnstrue
, ie.java.lang.String
listFilteringPredicates(PredicateGroup group, EvaluationContext context)
-
Methods inherited from class com.day.cq.search.eval.AbstractPredicateEvaluator
getOrderByComparator, getOrderByProperties, isFiltering
-
-
-
-
Method Detail
-
getXPathExpression
public java.lang.String getXPathExpression(Predicate p, EvaluationContext context)
Description copied from class:AbstractPredicateEvaluator
Default implementation that always returnsnull
, ie. adds nothing to the XPath query. Subclasses can choose whether they want to implement this method or use theAbstractPredicateEvaluator.includes(Predicate, Row, EvaluationContext)
method for advanced filtering (or both).- Specified by:
getXPathExpression
in interfacePredicateEvaluator
- Overrides:
getXPathExpression
in classAbstractPredicateEvaluator
- Parameters:
p
- predicate (for this evaluator type) which is evaluatedcontext
- helper class which provides access to various elements of the query evaluation- Returns:
- string containing an XPath predicateEvaluator expression
-
includes
public boolean includes(Predicate p, Row row, EvaluationContext context)
Description copied from class:AbstractPredicateEvaluator
Default implementation that always returnstrue
, ie. it does not "touch" the result set at all.- Specified by:
includes
in interfacePredicateEvaluator
- Overrides:
includes
in classAbstractPredicateEvaluator
- Parameters:
p
- predicate (for this evaluator type) which is evaluatedrow
- current row of the result set returned through the xpath querycontext
- helper class which provides access to various elements of the query evaluation- Returns:
true
if this row should be part of the final result set,false
if it should be dropped
-
canXpath
public boolean canXpath(Predicate predicate, EvaluationContext context)
Description copied from class:AbstractPredicateEvaluator
Returns the inverted boolean value of the deprecatedAbstractPredicateEvaluator.isFiltering(Predicate, EvaluationContext)
method (ie. if not overridden,true
).- Specified by:
canXpath
in interfacePredicateEvaluator
- Overrides:
canXpath
in classAbstractPredicateEvaluator
- Parameters:
predicate
- predicate (for this evaluator type) which is evaluatedcontext
- helper class which provides access to various elements of the query evaluation- Returns:
true
if this evaluator can express itself via xpath, ie.PredicateEvaluator.getXPathExpression(Predicate, EvaluationContext)
-
canFilter
public boolean canFilter(Predicate predicate, EvaluationContext context)
Description copied from class:AbstractPredicateEvaluator
Returns the same as the deprecatedAbstractPredicateEvaluator.isFiltering(Predicate, EvaluationContext)
method (ie. if not overridden,false
).- Specified by:
canFilter
in interfacePredicateEvaluator
- Overrides:
canFilter
in classAbstractPredicateEvaluator
- Parameters:
predicate
- predicate (for this evaluator type) which is evaluatedcontext
- helper class which provides access to various elements of the query evaluation- Returns:
true
if this evaluator can be express itself via filtering, ie.PredicateEvaluator.includes(Predicate, Row, EvaluationContext)
-
listFilteringPredicates
public java.lang.String listFilteringPredicates(PredicateGroup group, EvaluationContext context)
-
getFacetExtractor
public FacetExtractor getFacetExtractor(Predicate predicate, EvaluationContext context)
Description copied from class:AbstractPredicateEvaluator
Default implementation that always returnsnull
, ie. no facets will be extracted for the predicate.- Specified by:
getFacetExtractor
in interfacePredicateEvaluator
- Overrides:
getFacetExtractor
in classAbstractPredicateEvaluator
- Parameters:
predicate
- predicate (for this evaluator type) which is evaluatedcontext
- helper class which provides access to various elements of the query evaluation- Returns:
- a
FacetExtractor
that is used to create aFacet
ornull
if no extractor shall be provided
-
-