Record Class WildcardLikeShape
java.lang.Object
java.lang.Record
org.elasticsearch.xpack.esql.datasources.pushdown.WildcardLikeShape
- Record Components:
prefix- the literal prefix, ornullif the pattern starts with*literal- the literal middle substring, ornullif the pattern has fewer than two*runs or the middle segment is emptysuffix- the literal suffix, ornullif the pattern ends with*
public record WildcardLikeShape(org.apache.lucene.util.BytesRef prefix, org.apache.lucene.util.BytesRef literal, org.apache.lucene.util.BytesRef suffix)
extends Record
Shape decomposition for
WildcardLike patterns of the affix-contains family:
an optional literal prefix, an optional literal substring in the middle, and an optional
literal suffix. The pattern is represented as
prefix * literal * suffix
where any of the three literal segments may be empty (rendered as null on the result).
Recognized shapes — adjacent *s are collapsed during parsing, so **foo**bar*
is treated as *foo*bar* (and rejected; see below):
prefix*— one wildcard, only a prefix*suffix— one wildcard, only a suffixprefix*suffix— one wildcard, both affixes*literal*— two wildcards, only a middle literalprefix*literal*— two wildcards, prefix + middle*literal*suffix— two wildcards, middle + suffixprefix*literal*suffix— two wildcards, all three segments
Patterns that fall outside the family stay on the automaton path and produce null
from of(String):
- any
?— single-codepoint wildcard, awkward on UTF-8 byte boundaries - any
\\backslash anywhere in the pattern — escape handling would need to be consistent with Lucene's wildcard un-escaping per segment; rejecting outright keeps the parser bit-identical withByteRunAutomatonand avoids divergence risk - three or more unescaped, non-adjacent
*— would require multi-segment ordered contains, more complex than the affix-contains shape can express - an empty pattern — degenerate;
WildcardPatternguards against it upstream - a pattern with no
*— equivalent toEquals, which the logical optimizer already decomposes; not the responsibility of this parser
Bytes are committed to UTF-8 by way of BytesRef(CharSequence), matching
what KEYWORD values are encoded as on the read path.
-
Constructor Summary
ConstructorsConstructorDescriptionWildcardLikeShape(org.apache.lucene.util.BytesRef prefix, org.apache.lucene.util.BytesRef literal, org.apache.lucene.util.BytesRef suffix) Creates an instance of aWildcardLikeShaperecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.org.apache.lucene.util.BytesRefliteral()Returns the value of theliteralrecord component.booleanReturnstruewhen this shape selects every value (every component is absent).static WildcardLikeShapeReturns the shape of the given case-sensitiveWildcardLikepattern, ornullif the pattern is outside the affix-contains family (see the class-level docs).org.apache.lucene.util.BytesRefprefix()Returns the value of theprefixrecord component.org.apache.lucene.util.BytesRefsuffix()Returns the value of thesuffixrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
of
Returns the shape of the given case-sensitiveWildcardLikepattern, ornullif the pattern is outside the affix-contains family (see the class-level docs).Caller is responsible for the case-sensitivity check — this parser is intentionally blind to it so the rule is local.
-
matchesAll
public boolean matchesAll()Returnstruewhen this shape selects every value (every component is absent). Equivalent to aLIKE *pattern; callers typically have an upstreammatchesAllfast path that handles this without dispatching toByteMatchers.affixContains(org.apache.lucene.util.BytesRef, org.apache.lucene.util.BytesRef, org.apache.lucene.util.BytesRef, org.apache.lucene.util.BytesRef). -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
prefix
Returns the value of theprefixrecord component.- Returns:
- the value of the
prefixrecord component
-
literal
Returns the value of theliteralrecord component.- Returns:
- the value of the
literalrecord component
-
suffix
Returns the value of thesuffixrecord component.- Returns:
- the value of the
suffixrecord component
-