Class Knn
java.lang.Object
org.elasticsearch.xpack.esql.core.tree.Node<Expression>
org.elasticsearch.xpack.esql.core.expression.Expression
org.elasticsearch.xpack.esql.core.expression.function.Function
org.elasticsearch.xpack.esql.expression.function.fulltext.FullTextFunction
org.elasticsearch.xpack.esql.expression.function.vector.Knn
- All Implemented Interfaces:
NamedWriteable,Writeable,PostAnalysisPlanVerificationAware,PostOptimizationVerificationAware,TranslationAware,Resolvable,EvaluatorMapper,OptionalArgument,VectorFunction,ExpressionScoreMapper
public class Knn
extends FullTextFunction
implements OptionalArgument, VectorFunction, PostAnalysisPlanVerificationAware
-
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.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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionKnn(Source source, Expression field, Expression query, Expression k, Expression options) Knn(Source source, Expression field, Expression query, Expression k, Expression options, QueryBuilder queryBuilder, List<Expression> filterExpressions) -
Method Summary
Modifier and TypeMethodDescriptiondataType()booleanfield()inthashCode()protected NodeInfo<? extends Expression> info()k()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.replaceChildren(List<Expression> newChildren) replaceQueryBuilder(QueryBuilder queryBuilder) protected Expression.TypeResolutionResolves the type for the function parameters, as part of the type resolution for the functiontranslatable(LucenePushdownPredicates pushdownPredicates) Can this instance be translated or not? Usually checks whether the expression arguments are actual fields that exist in Lucene.protected Querytranslate(LucenePushdownPredicates pushdownPredicates, TranslatorHandler handler) withFilters(List<Expression> filterExpressions) voidwriteTo(StreamOutput out) Methods inherited from class org.elasticsearch.xpack.esql.expression.function.fulltext.FullTextFunction
asQuery, fieldAsFieldAttribute, fieldVerifier, functionType, getNameFromFieldAttribute, nullable, postOptimizationVerification, query, queryBuilder, resolveQuery, resolveType, toEvaluator, toScorerMethods 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, fold, foldable, 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, nodeName, nodeProperties, 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.xpack.esql.capabilities.TranslationAware
asLuceneQuery
-
Field Details
-
ENTRY
-
ALLOWED_OPTIONS
-
-
Constructor Details
-
Knn
-
Knn
public Knn(Source source, Expression field, Expression query, Expression k, Expression options, QueryBuilder queryBuilder, List<Expression> filterExpressions)
-
-
Method Details
-
field
-
k
-
options
-
filterExpressions
-
dataType
- Overrides:
dataTypein classFullTextFunction
-
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
-
queryAsObject
-
replaceQueryBuilder
- Specified by:
replaceQueryBuilderin classFullTextFunction
-
translatable
Description copied from interface:TranslationAwareCan this instance be translated or not? Usually checks whether the expression arguments are actual fields that exist in Lucene. SeeTranslationAware.Translatablefor precisely what can be signaled from this method.- Specified by:
translatablein interfaceTranslationAware- Overrides:
translatablein classFullTextFunction
-
translate
- Specified by:
translatein classFullTextFunction
-
withFilters
-
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.
-
replaceChildren
- Specified by:
replaceChildrenin classNode<Expression>
-
info
- Specified by:
infoin classNode<Expression>
-
getWriteableName
- Specified by:
getWriteableNamein interfaceNamedWriteable
-
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
equals
- Overrides:
equalsin classFullTextFunction
-
hashCode
public int hashCode()- Overrides:
hashCodein classFullTextFunction
-