Class MatchConstraint
- All Implemented Interfaces:
Constraint
The MatchConstraint
is commonly used to filter documents that contain a specific word, phrase, or exact value
in one or more indexed fields.
Examples
// Match documents where the "status" field is "open"
Constraint constraint = MatchConstraint.match("open", "status");
// Match across all indexed fields
Constraint constraint = MatchConstraint.match("open");
// Match across multiple fields with strict equality
Constraint constraint = MatchConstraint.match("PENDING", true, "status", "state");
Path Handling
You can provide one or more paths to target specific fields in the document. If no paths are provided, the constraint will match anywhere in the document. Empty or null paths are filtered out automatically.Matching Modes
The constraint supports two modes:strict = true
– uses exact string equality against the raw value of the entry.strict = false
(default) – uses normalized matching viaSearchUtils.normalize(String)
and compares to theasPhrase()
form of the entry (used for full-text search).
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Predicate
<Document.Entry> static Constraint
Creates a constraint that matches the given value across the specified paths, with an option to enforce strict string equality.static Constraint
Creates a constraint that performs non-strict (normalized) matching of the provided value across the specified paths.protected boolean
matches
(Document.Entry entry) Evaluates whether the specified document entry satisfies the condition defined by this method's implementation.Methods inherited from class io.fluxcapacitor.common.api.search.constraints.PathConstraint
checkPathBeforeEntry, getPaths, hasPathConstraint, matches, withPaths
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
-
MatchConstraint
public MatchConstraint()
-
-
Method Details
-
match
Creates a constraint that performs non-strict (normalized) matching of the provided value across the specified paths.If no paths are given, the match will be applied across all indexed fields in the document.
If the value is
null
, returns aNoOpConstraint
. If the value is aCollection
, creates a disjunction (AnyConstraint
) of match constraints for each non-null element. If the value implementsHasId
, thegetId()
value is used for matching. For all other types, the value is converted to a string.- Parameters:
value
- the value to matchpaths
- the paths to search in (or empty for all fields)- Returns:
- a
Constraint
instance orNoOpConstraint
-
match
Creates a constraint that matches the given value across the specified paths, with an option to enforce strict string equality.If no paths are given, the match will be applied across all indexed fields in the document.
If the value is
null
, returns aNoOpConstraint
. If the value is aCollection
, creates a disjunction (AnyConstraint
) of match constraints for each non-null element. If the value implementsHasId
, thegetId()
value is used for matching. For all other types, the value is converted to a string.- Parameters:
value
- the value to matchstrict
- iftrue
, use exact string matching; iffalse
, use normalized phrase matchpaths
- the paths to search in (or empty for all fields)- Returns:
- a
Constraint
instance orNoOpConstraint
-
matches
Description copied from class:PathConstraint
Evaluates whether the specified document entry satisfies the condition defined by this method's implementation.- Specified by:
matches
in classPathConstraint
- Parameters:
entry
- the document entry to evaluate- Returns:
true
if the entry satisfies the condition;false
otherwise
-
computeEntryMatcher
-