Class FacetConstraint
java.lang.Object
io.fluxzero.common.api.search.constraints.FacetConstraint
- All Implemented Interfaces:
Constraint
A constraint that matches documents containing a specific
FacetEntry.
Facets are indexed fields marked using @Facet annotations. Using this constraint allows for efficient lookups
because the facet matching is typically executed directly by the backing search store. This can make it significantly
faster than using a general MatchConstraint for the same purpose.
Example usage to match a single facet:
Constraint facetMatch = FacetConstraint.matchFacet("country", "Netherlands");
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanThis constraint does not apply to specific document paths, so this always returnsfalse.booleanEvaluates whether this constraint applies to the given document.static ConstraintmatchFacet(FacetEntry facet) Factory method to create a constraint that matches a singleFacetEntry.static ConstraintmatchFacet(String name, Object value) Factory method to create a constraint that matches documents with the given facet name and value.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Constraint
and, decompose, or
-
Constructor Details
-
FacetConstraint
public FacetConstraint()
-
-
Method Details
-
matchFacet
Factory method to create a constraint that matches documents with the given facet name and value.If the value is a
Collection, multiple facets are matched using anAnyConstraintover the individual values. If the value is aHasId, its identifier is used for matching.- Parameters:
name- the facet field name (normalized internally)value- the expected facet value- Returns:
- a
FacetConstraintor a composite constraint ifvalueis a collection, orNoOpConstraintif the name is null or the value is null/empty.
-
matchFacet
Factory method to create a constraint that matches a singleFacetEntry.- Parameters:
facet- the facet to match- Returns:
- a
FacetConstraintfor the provided facet or aNoOpConstraintif the facet is null
-
matches
Description copied from interface:ConstraintEvaluates whether this constraint applies to the given document.- Specified by:
matchesin interfaceConstraint- Parameters:
document- the document to test- Returns:
trueif the constraint matches the document
-
hasPathConstraint
public boolean hasPathConstraint()This constraint does not apply to specific document paths, so this always returnsfalse.- Specified by:
hasPathConstraintin interfaceConstraint- Returns:
trueif path-based filtering is involved
-