Class FacetConstraint
java.lang.Object
io.fluxcapacitor.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 TypeMethodDescriptionboolean
This constraint does not apply to specific document paths, so this always returnsfalse
.boolean
Evaluates whether this constraint applies to the given document.static Constraint
matchFacet
(FacetEntry facet) Factory method to create a constraint that matches a singleFacetEntry
.static Constraint
matchFacet
(String name, Object value) Factory method to create a constraint that matches documents with the given facet name and value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.common.api.search.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 anAnyConstraint
over 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
FacetConstraint
or a composite constraint ifvalue
is a collection, orNoOpConstraint
if 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
FacetConstraint
for the provided facet or aNoOpConstraint
if the facet is null
-
matches
Description copied from interface:Constraint
Evaluates whether this constraint applies to the given document.- Specified by:
matches
in interfaceConstraint
- Parameters:
document
- the document to test- Returns:
true
if the constraint matches the document
-
hasPathConstraint
public boolean hasPathConstraint()This constraint does not apply to specific document paths, so this always returnsfalse
.- Specified by:
hasPathConstraint
in interfaceConstraint
- Returns:
true
if path-based filtering is involved
-