Limiting the relations accepted for computation of HierarchyWithin / HierarchyWithinRoot / FacetSummary / HierarchyStatistics
The HierarchyWithin only uses a filter constraint that selects the considered node for the hierarchy lookup, the same is true for FacetSummary and HierarchyStatistics.
However, there might be a use case where the client wants to consider only those relations to the target entities that match a certain constraint.
Let's look at this picture:

What if we want to consider only relations with attribute disabled="false" and want to list all products in category (hierarchy node) two?! Currently, product 1 would be returned even if we use the additional constraint referenceHaving(attributeEqualsFalse("disabled")) because it has another relation to another node with attribute disabled set to true.
Therefore, we need a new way to specify which relations should be considered when evaluating relation constraints. We came up with the following idea:
In filter section:
hierarchyWithin(
attributeEquals("code", "ABC"),
considerReferencesHaving(
attributeEqualsFalse("disabled")
)
excluding(
attributeEquals("code", "DEF")
)
)
In requirements:
facetSummary(
filterBy(
inRange("validity", now())
)
filterGroupBy(
attributeEqualsTrue("filterable")
)
considerReferencesHaving(
attributeEqualsFalse("disabled")
)
)
We first thought about reusing the referenceHaving constraint, but it also allows an entityHaving sub-constraint, which doesn't make sense in this situation. Therefore, we think we need a differently named constraint container that would accept filtering constraints that target only attributes of the reference and nothing else.