Class SingleFieldFullTextFunction
- All Implemented Interfaces:
NamedWriteable,Writeable,PostAnalysisPlanVerificationAware,PostOptimizationPlanVerificationAware,PostOptimizationVerificationAware,RewriteableAware,TranslationAware,Resolvable,EvaluatorMapper,ExpressionScoreMapper
- Direct Known Subclasses:
Knn,Match,MatchPhrase
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.xpack.esql.core.expression.Expression
Expression.TypeResolutionNested classes/interfaces inherited from interface org.elasticsearch.xpack.esql.evaluator.mapper.EvaluatorMapper
EvaluatorMapper.ToEvaluatorNested classes/interfaces inherited from interface org.elasticsearch.xpack.esql.score.ExpressionScoreMapper
ExpressionScoreMapper.ToScorerNested classes/interfaces inherited from interface org.elasticsearch.xpack.esql.capabilities.PostOptimizationVerificationAware
PostOptimizationVerificationAware.CoordinatorOnlyNested classes/interfaces inherited from interface org.elasticsearch.xpack.esql.capabilities.TranslationAware
TranslationAware.FinishedTranslatable, TranslationAware.SingleValueTranslationAware, TranslationAware.TranslatableNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsFields inherited from class org.elasticsearch.xpack.esql.core.tree.Node
TO_STRING_MAX_WIDTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSingleFieldFullTextFunction(Source source, Expression field, Expression query, Expression options, List<Expression> children, QueryBuilder queryBuilder) -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected StringReturns a human-readable string listing the expected field types.protected StringReturns a human-readable string listing the expected query types.field()protected FieldAttributeReturns the field as a FieldAttribute for use in query translationfold(FoldContext ctx) booleanfoldable()Returns the allowed options map for this function.Returns the set of allowed data types for the field parameter.Returns the set of allowed data types for the query parameter.inthashCode()nullable()options()Allows the implementer to return a consumer that will perform self-validation in the context of the tree structure the implementer is part of.Validates the implementing expression - discovered failures are reported to the givenFailuresclass.protected ObjectConverts the query expression to an Object suitable for the Lucene query.protected Expression.TypeResolutionResolves and validates the field parameter type.protected Expression.TypeResolutionResolves and validates the options parameter.protected Expression.TypeResolutionResolves the type for the function parameters, as part of the type resolution for the functionprotected Expression.TypeResolutionResolves and validates the query parameter type.Methods inherited from class org.elasticsearch.xpack.esql.expression.function.fulltext.FullTextFunction
asQuery, dataType, evaluatorQueryBuilder, fieldAsFieldAttribute, fieldVerifier, functionType, getNameFromFieldAttribute, postOptimizationVerification, query, queryBuilder, resolveQuery, resolveType, toEvaluator, toScorer, translatable, translateMethods inherited from class org.elasticsearch.xpack.esql.core.expression.function.Function
arguments, functionName, nodeStringMethods inherited from class org.elasticsearch.xpack.esql.core.expression.Expression
canonical, canonicalize, childrenResolved, propertiesToString, references, resolved, semanticEquals, semanticHash, toString, typeResolvedMethods inherited from class org.elasticsearch.xpack.esql.core.tree.Node
anyMatch, children, collect, collectFirstChildren, collectLeaves, doCollectFirst, forEachDown, forEachDown, forEachDownMayReturnEarly, forEachProperty, forEachPropertyDown, forEachPropertyOnly, forEachPropertyUp, forEachUp, forEachUp, info, nodeName, nodeProperties, replaceChildren, replaceChildrenSameSize, source, sourceLocation, sourceText, transformChildren, transformDown, transformDown, transformDown, transformNodeProps, transformPropertiesDown, transformPropertiesOnly, transformPropertiesUp, transformUp, transformUp, transformUpMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xpack.esql.evaluator.mapper.EvaluatorMapper
foldMethods inherited from interface org.elasticsearch.common.io.stream.NamedWriteable
getWriteableNameMethods inherited from interface org.elasticsearch.xpack.esql.capabilities.RewriteableAware
replaceQueryBuilderMethods inherited from interface org.elasticsearch.xpack.esql.capabilities.TranslationAware
asLuceneQuery
-
Field Details
-
field
-
-
Constructor Details
-
SingleFieldFullTextFunction
protected SingleFieldFullTextFunction(Source source, Expression field, Expression query, Expression options, List<Expression> children, QueryBuilder queryBuilder)
-
-
Method Details
-
field
-
options
-
resolveParams
Description copied from class:FullTextFunctionResolves the type for the function parameters, as part of the type resolution for the function- Overrides:
resolveParamsin classFullTextFunction- Returns:
- type resolution for the function parameters
-
resolveField
Resolves and validates the field parameter type. -
resolveQuery
Resolves and validates the query parameter type. -
resolveOptions
Resolves and validates the options parameter. Subclasses can override to add custom validation. -
queryAsObject
Converts the query expression to an Object suitable for the Lucene query. Handles common conversions for BytesRef, UNSIGNED_LONG, DATETIME, and DATE_NANOS. -
fieldAsFieldAttribute
Returns the field as a FieldAttribute for use in query translation -
foldable
public boolean foldable()- Overrides:
foldablein classExpression
-
fold
- Overrides:
foldin classExpression
-
nullable
- Overrides:
nullablein classFullTextFunction
-
postAnalysisPlanVerification
Description copied from interface:PostAnalysisPlanVerificationAwareAllows the implementer to return a consumer that will perform self-validation in the context of the tree structure the implementer is part of. This usually involves checking the type and configuration of the children or that of the parent.It is often more useful to perform the checks as extended as it makes sense, over stopping at the first failure. This will allow the author to progress faster to a correct query.
Example: a
GroupingFunctioninstance, which models a function to group documents to aggregate over, can only be used in the context of the STATS command, modeled by theAggregateclass. This is how this verification is performed:@Override public BiConsumer<LogicalPlan, Failures> postAnalysisPlanVerification() { return (p, failures) -> { if (p instanceof Aggregate == false) { p.forEachExpression( GroupingFunction.class, gf -> failures.add(fail(gf, "cannot use grouping function [{}] outside of a STATS command", gf.sourceText())) ); } }; }- Specified by:
postAnalysisPlanVerificationin interfacePostAnalysisPlanVerificationAware- Overrides:
postAnalysisPlanVerificationin classFullTextFunction- Returns:
- a consumer that will receive a tree to check and an accumulator of failures found during inspection.
-
postOptimizationPlanVerification
Description copied from interface:PostOptimizationPlanVerificationAwareValidates the implementing expression - discovered failures are reported to the givenFailuresclass.Example: the SORT command,
OrderBy, can only be executed currently if it can be associated with a LIMITLimitand together transformed into aTopN(which is executable). The replacement of the LIMIT+SORT into a TopN is done at the end of the optimization phase. This means that any SORT still existing in the plan post optimization is an error. However, there can be a LIMIT in the plan, but separated from the SORT by an INLINE STATS; in this case, the LIMIT cannot be pushed down near the SORT. To inform the user how they need to modify the query so it can be run, we implement this:@Override public BiConsumer<LogicalPlan, Failures> postOptimizationPlanVerification() { return (p, failures) -> { if (p instanceof InlineJoin inlineJoin) { inlineJoin.forEachUp(OrderBy.class, orderBy -> { failures.add( fail( inlineJoin, "unbounded SORT [{}] not supported before INLINE STATS [{}], move the sort after the INLINE STATS", orderBy.sourceText(), inlineJoin.sourceText() ) ); }); } else if (p instanceof OrderBy) { failures.add(fail(p, "Unbounded SORT not supported yet [{}] please add a LIMIT", p.sourceText())); } }; }If we didn't need to check the structure of the plan, it would have sufficed to implement the
PostOptimizationVerificationAwareinterface, which would simply check if there is an instance ofOrderByin the plan.- Specified by:
postOptimizationPlanVerificationin interfacePostOptimizationPlanVerificationAware- Returns:
- a consumer that will receive a tree to check and an accumulator of failures found during inspection.
-
equals
- Overrides:
equalsin classFullTextFunction
-
hashCode
public int hashCode()- Overrides:
hashCodein classFullTextFunction
-
getFieldDataTypes
Returns the set of allowed data types for the field parameter. Each subclass defines which field types it supports. -
getQueryDataTypes
Returns the set of allowed data types for the query parameter. Each subclass defines which query types it supports. -
getAllowedOptions
Returns the allowed options map for this function. Keys are option names, values are the expected data types. -
expectedFieldTypesString
Returns a human-readable string listing the expected field types. Used in error messages. -
expectedQueryTypesString
Returns a human-readable string listing the expected query types. Used in error messages.
-