From f294ca54b52e71d47f7b82558e3a9c9418b7d23b Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 7 Oct 2025 17:56:54 +0200 Subject: [PATCH 01/18] Enable text_embedding function in non-snapshot builds. --- .../elasticsearch/xpack/esql/action/EsqlCapabilities.java | 2 +- .../esql/expression/function/EsqlFunctionRegistry.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java index d701d69652751..e80ebee86ffc6 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java @@ -1243,7 +1243,7 @@ public enum Cap { /** * Support for the {@code TEXT_EMBEDDING} function for generating dense vector embeddings. */ - TEXT_EMBEDDING_FUNCTION(Build.current().isSnapshot()), + TEXT_EMBEDDING_FUNCTION, /** * Support for the LIKE operator with a list of wildcards. diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java index 8553b3f587372..96136d36656f6 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java @@ -526,7 +526,9 @@ private static FunctionDefinition[][] functions() { def(AbsentOverTime.class, uni(AbsentOverTime::new), "absent_over_time"), def(AvgOverTime.class, uni(AvgOverTime::new), "avg_over_time"), def(LastOverTime.class, uni(LastOverTime::new), "last_over_time"), - def(FirstOverTime.class, uni(FirstOverTime::new), "first_over_time") } }; + def(FirstOverTime.class, uni(FirstOverTime::new), "first_over_time"), + // dense vector function + def(TextEmbedding.class, bi(TextEmbedding::new), "text_embedding")}}; } @@ -545,8 +547,7 @@ private static FunctionDefinition[][] snapshotFunctions() { def(L1Norm.class, L1Norm::new, "v_l1_norm"), def(L2Norm.class, L2Norm::new, "v_l2_norm"), def(Magnitude.class, Magnitude::new, "v_magnitude"), - def(Hamming.class, Hamming::new, "v_hamming"), - def(TextEmbedding.class, bi(TextEmbedding::new), "text_embedding") } }; + def(Hamming.class, Hamming::new, "v_hamming")}}; } public EsqlFunctionRegistry snapshotRegistry() { From 5f10061f050aeeb786e614255d6fff809308e10d Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 7 Oct 2025 17:57:40 +0200 Subject: [PATCH 02/18] Regenerate documentation for the TEXT_EMBEDDING function. --- .../esql/_snippets/functions/layout/text_embedding.md | 2 +- .../esql/kibana/definition/functions/text_embedding.json | 2 +- .../xpack/esql/expression/function/inference/TextEmbedding.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/reference/query-languages/esql/_snippets/functions/layout/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/layout/text_embedding.md index a120fff2d7a22..b7d87984e6ad6 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/layout/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/layout/text_embedding.md @@ -2,7 +2,7 @@ ## `TEXT_EMBEDDING` [esql-text_embedding] ```{applies_to} -stack: development +stack: preview 9.3 serverless: preview ``` diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json index 343cf597a0a53..ef9701793ff7d 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json @@ -27,5 +27,5 @@ "ROW input=\"Who is Victor Hugo?\"\n| EVAL embedding = TEXT_EMBEDDING(\"Who is Victor Hugo?\", \"test_dense_inference\")\n;" ], "preview" : true, - "snapshot_only" : true + "snapshot_only" : false } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java index ab8b8c8c3f3c9..0f3f6825a3a9e 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java @@ -41,7 +41,7 @@ public class TextEmbedding extends InferenceFunction { @FunctionInfo( returnType = "dense_vector", description = "Generates dense vector embeddings for text using a specified inference endpoint.", - appliesTo = { @FunctionAppliesTo(lifeCycle = FunctionAppliesToLifecycle.DEVELOPMENT) }, + appliesTo = {@FunctionAppliesTo(version = "9.3", lifeCycle = FunctionAppliesToLifecycle.PREVIEW)}, preview = true, examples = { @Example( From 25acbf1c4be599d43806eb64904facdfef4bd243 Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 7 Oct 2025 17:58:14 +0200 Subject: [PATCH 03/18] Clean useless conditional in tests. --- .../function/EsqlFunctionRegistry.java | 4 +-- .../xpack/esql/analysis/AnalyzerTests.java | 12 ------- .../xpack/esql/analysis/VerifierTests.java | 2 -- .../inference/TextEmbeddingErrorTests.java | 8 ----- .../inference/TextEmbeddingTests.java | 7 ---- .../inference/InferenceResolverTests.java | 33 +++++++++---------- 6 files changed, 17 insertions(+), 49 deletions(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java index 96136d36656f6..3c8ffb45585db 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java @@ -528,7 +528,7 @@ private static FunctionDefinition[][] functions() { def(LastOverTime.class, uni(LastOverTime::new), "last_over_time"), def(FirstOverTime.class, uni(FirstOverTime::new), "first_over_time"), // dense vector function - def(TextEmbedding.class, bi(TextEmbedding::new), "text_embedding")}}; + def(TextEmbedding.class, bi(TextEmbedding::new), "text_embedding") } }; } @@ -547,7 +547,7 @@ private static FunctionDefinition[][] snapshotFunctions() { def(L1Norm.class, L1Norm::new, "v_l1_norm"), def(L2Norm.class, L2Norm::new, "v_l2_norm"), def(Magnitude.class, Magnitude::new, "v_magnitude"), - def(Hamming.class, Hamming::new, "v_hamming")}}; + def(Hamming.class, Hamming::new, "v_hamming") } }; } public EsqlFunctionRegistry snapshotRegistry() { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java index 096b2a1f5c3fe..1a096df1b0648 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java @@ -3814,8 +3814,6 @@ private void assertEmptyEsRelation(LogicalPlan plan) { } public void testTextEmbeddingResolveInferenceId() { - assumeTrue("TEXT_EMBEDDING function required", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled()); - LogicalPlan plan = analyze( String.format(Locale.ROOT, """ FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING("italian food recipe", "%s")""", TEXT_EMBEDDING_INFERENCE_ID), @@ -3833,8 +3831,6 @@ public void testTextEmbeddingResolveInferenceId() { } public void testTextEmbeddingFunctionResolveType() { - assumeTrue("TEXT_EMBEDDING function required", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled()); - LogicalPlan plan = analyze( String.format(Locale.ROOT, """ FROM books METADATA _score| EVAL embedding = TEXT_EMBEDDING("italian food recipe", "%s")""", TEXT_EMBEDDING_INFERENCE_ID), @@ -3853,8 +3849,6 @@ public void testTextEmbeddingFunctionResolveType() { } public void testTextEmbeddingFunctionMissingInferenceIdError() { - assumeTrue("TEXT_EMBEDDING function required", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled()); - VerificationException ve = expectThrows( VerificationException.class, () -> analyze( @@ -3868,8 +3862,6 @@ public void testTextEmbeddingFunctionMissingInferenceIdError() { } public void testTextEmbeddingFunctionInvalidInferenceIdError() { - assumeTrue("TEXT_EMBEDDING function required", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled()); - String inferenceId = randomInferenceIdOtherThan(TEXT_EMBEDDING_INFERENCE_ID); VerificationException ve = expectThrows( VerificationException.class, @@ -3887,8 +3879,6 @@ public void testTextEmbeddingFunctionInvalidInferenceIdError() { } public void testTextEmbeddingFunctionWithoutModel() { - assumeTrue("TEXT_EMBEDDING function required", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled()); - ParsingException ve = expectThrows(ParsingException.class, () -> analyze(""" FROM books METADATA _score| EVAL embedding = TEXT_EMBEDDING("italian food recipe")""", "mapping-books.json")); @@ -3899,8 +3889,6 @@ public void testTextEmbeddingFunctionWithoutModel() { } public void testKnnFunctionWithTextEmbedding() { - assumeTrue("TEXT_EMBEDDING function required", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled()); - LogicalPlan plan = analyze( String.format(Locale.ROOT, """ from test | where KNN(float_vector, TEXT_EMBEDDING("italian food recipe", "%s"))""", TEXT_EMBEDDING_INFERENCE_ID), diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java index 4aeeb693779d7..389fadfed1693 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java @@ -2735,7 +2735,6 @@ public void testSortInTimeSeries() { } public void testTextEmbeddingFunctionInvalidQuery() { - assumeTrue("TEXT_EMBEDDING is not enabled", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled()); assertThat( error("from test | EVAL embedding = TEXT_EMBEDDING(null, ?)", defaultAnalyzer, TEXT_EMBEDDING_INFERENCE_ID), equalTo("1:30: first argument of [TEXT_EMBEDDING(null, ?)] cannot be null, received [null]") @@ -2753,7 +2752,6 @@ public void testTextEmbeddingFunctionInvalidQuery() { } public void testTextEmbeddingFunctionInvalidInferenceId() { - assumeTrue("TEXT_EMBEDDING is not enabled", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled()); assertThat( error("from test | EVAL embedding = TEXT_EMBEDDING(?, null)", defaultAnalyzer, "query text"), equalTo("1:30: second argument of [TEXT_EMBEDDING(?, null)] cannot be null, received [null]") diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbeddingErrorTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbeddingErrorTests.java index 3864c8ccc8685..63f3bf350db91 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbeddingErrorTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbeddingErrorTests.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.esql.expression.function.inference; -import org.elasticsearch.xpack.esql.action.EsqlCapabilities; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.expression.TypeResolutions; import org.elasticsearch.xpack.esql.core.tree.Source; @@ -16,7 +15,6 @@ import org.elasticsearch.xpack.esql.expression.function.ErrorsForCasesWithoutExamplesTestCase; import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; import org.hamcrest.Matcher; -import org.junit.Before; import java.util.List; import java.util.Locale; @@ -28,12 +26,6 @@ * Tests error conditions and type validation for TEXT_EMBEDDING function. */ public class TextEmbeddingErrorTests extends ErrorsForCasesWithoutExamplesTestCase { - - @Before - public void checkCapability() { - assumeTrue("TEXT_EMBEDDING is not enabled", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled()); - } - @Override protected List cases() { return paramsToSuppliers(TextEmbeddingTests.parameters()); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbeddingTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbeddingTests.java index f7a1ed4cf2025..4389afd60bde1 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbeddingTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbeddingTests.java @@ -10,14 +10,12 @@ import com.carrotsearch.randomizedtesting.annotations.Name; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; -import org.elasticsearch.xpack.esql.action.EsqlCapabilities; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.expression.function.AbstractFunctionTestCase; import org.elasticsearch.xpack.esql.expression.function.FunctionName; import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; import org.hamcrest.Matchers; -import org.junit.Before; import java.util.List; import java.util.function.Supplier; @@ -28,11 +26,6 @@ @FunctionName("text_embedding") public class TextEmbeddingTests extends AbstractFunctionTestCase { - @Before - public void checkCapability() { - assumeTrue("TEXT_EMBEDDING is not enabled", EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled()); - } - public TextEmbeddingTests(@Name("TestCase") Supplier testCaseSupplier) { this.testCase = testCaseSupplier.get(); } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/inference/InferenceResolverTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/inference/InferenceResolverTests.java index 8ccda8a7010d1..30a711541f831 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/inference/InferenceResolverTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/inference/InferenceResolverTests.java @@ -23,7 +23,6 @@ import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xpack.core.inference.action.GetInferenceModelAction; -import org.elasticsearch.xpack.esql.action.EsqlCapabilities; import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry; import org.elasticsearch.xpack.esql.parser.EsqlParser; import org.junit.After; @@ -84,25 +83,23 @@ public void testCollectInferenceIds() { List.of("completion-inference-id") ); - if (EsqlCapabilities.Cap.TEXT_EMBEDDING_FUNCTION.isEnabled()) { - // Text embedding inference plan - assertCollectInferenceIds( - "FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING(\"description\", \"text-embedding-inference-id\")", - List.of("text-embedding-inference-id") - ); + // Text embedding function + assertCollectInferenceIds( + "FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING(\"description\", \"text-embedding-inference-id\")", + List.of("text-embedding-inference-id") + ); - // Test inference ID collection from an inference function - assertCollectInferenceIds( - "FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING(\"description\", \"text-embedding-inference-id\")", - List.of("text-embedding-inference-id") - ); + // Test inference ID collection from an inference function + assertCollectInferenceIds( + "FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING(\"description\", \"text-embedding-inference-id\")", + List.of("text-embedding-inference-id") + ); - // Test inference ID collection with nested functions - assertCollectInferenceIds( - "FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING(TEXT_EMBEDDING(\"nested\", \"nested-id\"), \"outer-id\")", - List.of("nested-id", "outer-id") - ); - } + // Test inference ID collection with nested functions + assertCollectInferenceIds( + "FROM books METADATA _score | EVAL embedding = TEXT_EMBEDDING(TEXT_EMBEDDING(\"nested\", \"nested-id\"), \"outer-id\")", + List.of("nested-id", "outer-id") + ); // Multiple inference plans assertCollectInferenceIds(""" From 791f036981d809d736f69e975de570029e104175 Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 7 Oct 2025 17:58:54 +0200 Subject: [PATCH 04/18] Lint --- .../xpack/esql/expression/function/inference/TextEmbedding.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java index 0f3f6825a3a9e..c71646f3caf3a 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java @@ -41,7 +41,7 @@ public class TextEmbedding extends InferenceFunction { @FunctionInfo( returnType = "dense_vector", description = "Generates dense vector embeddings for text using a specified inference endpoint.", - appliesTo = {@FunctionAppliesTo(version = "9.3", lifeCycle = FunctionAppliesToLifecycle.PREVIEW)}, + appliesTo = { @FunctionAppliesTo(version = "9.3", lifeCycle = FunctionAppliesToLifecycle.PREVIEW) }, preview = true, examples = { @Example( From ee2b64a79d0f4660e5136c5afeed28207fbf8adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20FOUCRET?= Date: Tue, 7 Oct 2025 18:01:55 +0200 Subject: [PATCH 05/18] Update docs/changelog/136103.yaml --- docs/changelog/136103.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/changelog/136103.yaml diff --git a/docs/changelog/136103.yaml b/docs/changelog/136103.yaml new file mode 100644 index 0000000000000..a01e08ee086f8 --- /dev/null +++ b/docs/changelog/136103.yaml @@ -0,0 +1,5 @@ +pr: 136103 +summary: Enable the TEXT_EMBEDDING function in non-snapshot build +area: ES|QL +type: feature +issues: [] From e958a1156c0227887a1113f9282ce635d9036669 Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 7 Oct 2025 18:09:19 +0200 Subject: [PATCH 06/18] Update usage to make sure text_embedding function is present in non-snapshot builds. --- .../yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml index 57d5bb7adb0df..7ae01e1dd807d 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml @@ -259,6 +259,7 @@ setup: - set: { esql.functions.to_long: functions_to_long } - set: { esql.functions.coalesce: functions_coalesce } - set: { esql.functions.categorize: functions_categorize } + - set: {esql.functions.text_embedding: functions_text_embedding} - do: esql.query: @@ -302,6 +303,7 @@ setup: - gt: { esql.functions.to_long: $functions_to_long } - match: { esql.functions.coalesce: $functions_coalesce } - gt: { esql.functions.categorize: $functions_categorize } + - match: {esql.functions.text_embedding: $functions_text_embedding} - set: { esql.features.limit: limit_counter } - set: { esql.features.sort: sort_counter } From 2ad68019c16991e0c947d126c9586a2232b254e7 Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 7 Oct 2025 18:57:34 +0200 Subject: [PATCH 07/18] Add text_embedding to the doc. --- .../esql/_snippets/lists/dense-vector-functions.md | 1 + .../esql/functions-operators/dense-vector-functions.md | 3 +++ 2 files changed, 4 insertions(+) diff --git a/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md b/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md index 3b54078e40bf2..693b503844e08 100644 --- a/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md +++ b/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md @@ -1,4 +1,5 @@ * {applies_to}`stack: preview 9.2` {applies_to}`serverless: preview` [`KNN`](../../functions-operators/dense-vector-functions.md#esql-knn) +* {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`TEXT_EMBEDDING`](../../functions-operators/dense-vector-functions.md#esql-text-embnedding) % * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`V_COSINE`](../../functions-operators/dense-vector-functions.md#esql-v_cosine) % * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`V_DOT_PRODUCT`](../../functions-operators/dense-vector-functions.md#esql-v_dot_product) diff --git a/docs/reference/query-languages/esql/functions-operators/dense-vector-functions.md b/docs/reference/query-languages/esql/functions-operators/dense-vector-functions.md index d384eacc63a0d..da56b64ee8ff5 100644 --- a/docs/reference/query-languages/esql/functions-operators/dense-vector-functions.md +++ b/docs/reference/query-languages/esql/functions-operators/dense-vector-functions.md @@ -23,6 +23,9 @@ and require appropriate field mappings. :::{include} ../_snippets/functions/layout/knn.md ::: +:::{include} ../_snippets/functions/layout/text_embedding.md +::: + % V_COSINE is currently a hidden feature % To make it visible again, uncomment this and the line in % lists/dense-vector-functions.md From c3df8c75b1b96f07a770829c466429c610379f2d Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 7 Oct 2025 19:03:43 +0200 Subject: [PATCH 08/18] Fix typo. --- .../esql/_snippets/lists/dense-vector-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md b/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md index 693b503844e08..562f89bee228b 100644 --- a/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md +++ b/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md @@ -1,5 +1,5 @@ * {applies_to}`stack: preview 9.2` {applies_to}`serverless: preview` [`KNN`](../../functions-operators/dense-vector-functions.md#esql-knn) -* {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`TEXT_EMBEDDING`](../../functions-operators/dense-vector-functions.md#esql-text-embnedding) +* {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`TEXT_EMBEDDING`](../../functions-operators/dense-vector-functions.md#esql-text-embedding) % * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`V_COSINE`](../../functions-operators/dense-vector-functions.md#esql-v_cosine) % * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`V_DOT_PRODUCT`](../../functions-operators/dense-vector-functions.md#esql-v_dot_product) From 7349c8834e15365aa919a930ace260b75c1459f3 Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 7 Oct 2025 19:09:25 +0200 Subject: [PATCH 09/18] Fix typo again ... --- .../esql/_snippets/lists/dense-vector-functions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md b/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md index 562f89bee228b..14f5365b4fc6e 100644 --- a/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md +++ b/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md @@ -1,5 +1,6 @@ * {applies_to}`stack: preview 9.2` {applies_to}`serverless: preview` [`KNN`](../../functions-operators/dense-vector-functions.md#esql-knn) -* {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`TEXT_EMBEDDING`](../../functions-operators/dense-vector-functions.md#esql-text-embedding) +* {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [ + `TEXT_EMBEDDING`](../../functions-operators/dense-vector-functions.md#esql-text_embedding) % * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`V_COSINE`](../../functions-operators/dense-vector-functions.md#esql-v_cosine) % * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`V_DOT_PRODUCT`](../../functions-operators/dense-vector-functions.md#esql-v_dot_product) From 6803a51c19a5ffa65f8cf5b0e43a4e03ae836f75 Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 7 Oct 2025 19:34:56 +0200 Subject: [PATCH 10/18] Update examples. --- .../functions/description/text_embedding.md | 2 +- .../functions/examples/text_embedding.md | 16 +++++++++++++++- .../functions/parameters/text_embedding.md | 2 +- .../definition/functions/text_embedding.json | 8 +++++--- .../kibana/docs/functions/text_embedding.md | 2 +- .../main/resources/text-embedding.csv-spec | 8 ++++++-- .../function/inference/TextEmbedding.java | 19 ++++++++++++++----- 7 files changed, 43 insertions(+), 14 deletions(-) diff --git a/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md index 70ebddbdb7c0a..ae550ad09adc4 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md @@ -2,5 +2,5 @@ **Description** -Generates dense vector embeddings for text using a specified inference endpoint. +Generates dense vector embeddings from a text using a specified inference endpoint. diff --git a/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md index 71d05c9524350..914ceb472b7da 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md @@ -1,6 +1,6 @@ % This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it. -**Example** +**Examples** Generate text embeddings using the 'test_dense_inference' inference endpoint. @@ -10,4 +10,18 @@ ROW input="Who is Victor Hugo?" ; ``` +Generate text embeddings for use within a KNN search. + +```esql +FROM semantic_text METADATA _score +| EVAL query_embedding = TEXT_EMBEDDING("be excellent to each other", "test_dense_inference") +| WHERE KNN(semantic_text_dense_field, query_embedding) +``` + +Generate text embeddings inline within a KNN search. + +```esql +null +``` + diff --git a/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md index 80175caaf09dd..6c83af7412f12 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md @@ -6,5 +6,5 @@ : Text to generate embeddings from `inference_id` -: Identifier of the inference endpoint +: Identifier of the inference endpoint. The inference endpoint must have the `text_embedding` task type. diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json index ef9701793ff7d..ab0e17bfc256a 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json @@ -2,7 +2,7 @@ "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.", "type" : "scalar", "name" : "text_embedding", - "description" : "Generates dense vector embeddings for text using a specified inference endpoint.", + "description" : "Generates dense vector embeddings from a text using a specified inference endpoint.", "signatures" : [ { "params" : [ @@ -16,7 +16,7 @@ "name" : "inference_id", "type" : "keyword", "optional" : false, - "description" : "Identifier of the inference endpoint" + "description" : "Identifier of the inference endpoint. The inference endpoint must have the `text_embedding` task type." } ], "variadic" : false, @@ -24,7 +24,9 @@ } ], "examples" : [ - "ROW input=\"Who is Victor Hugo?\"\n| EVAL embedding = TEXT_EMBEDDING(\"Who is Victor Hugo?\", \"test_dense_inference\")\n;" + "ROW input=\"Who is Victor Hugo?\"\n| EVAL embedding = TEXT_EMBEDDING(\"Who is Victor Hugo?\", \"test_dense_inference\")\n;", + "FROM semantic_text METADATA _score\n| EVAL query_embedding = TEXT_EMBEDDING(\"be excellent to each other\", \"test_dense_inference\")\n| WHERE KNN(semantic_text_dense_field, query_embedding)", + null ], "preview" : true, "snapshot_only" : false diff --git a/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md b/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md index f8981fb3be66a..7d78c24384c62 100644 --- a/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md +++ b/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md @@ -1,7 +1,7 @@ % This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it. ### TEXT EMBEDDING -Generates dense vector embeddings for text using a specified inference endpoint. +Generates dense vector embeddings from a text using a specified inference endpoint. ```esql ROW input="Who is Victor Hugo?" diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/text-embedding.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/text-embedding.csv-spec index 86e0fcd0eb6a4..c83adf4cc1580 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/text-embedding.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/text-embedding.csv-spec @@ -2,11 +2,11 @@ text_embedding using a row source operator required_capability: text_embedding_function required_capability: dense_vector_field_type_released -// tag::embedding-eval[] +// tag::text-embedding-eval[] ROW input="Who is Victor Hugo?" | EVAL embedding = TEXT_EMBEDDING("Who is Victor Hugo?", "test_dense_inference") ; -// end::embedding-eval[] +// end::text-embedding-eval[] input:keyword | embedding:dense_vector Who is Victor Hugo? | [56.0, 50.0, 48.0] @@ -32,9 +32,11 @@ required_capability: dense_vector_field_type_released required_capability: knn_function_v5 required_capability: semantic_text_field_caps +// tag::text-embedding-knn[] FROM semantic_text METADATA _score | EVAL query_embedding = TEXT_EMBEDDING("be excellent to each other", "test_dense_inference") | WHERE KNN(semantic_text_dense_field, query_embedding) +// end::text-embedding-knn[] | SORT _score DESC | LIMIT 10 | KEEP semantic_text_field, query_embedding @@ -52,8 +54,10 @@ required_capability: dense_vector_field_type_released required_capability: knn_function_v5 required_capability: semantic_text_field_caps +// tag::text-embedding-knn-inline[] FROM semantic_text METADATA _score | WHERE KNN(semantic_text_dense_field, TEXT_EMBEDDING("be excellent to each other", "test_dense_inference")) +// end::text-text-embedding-knn-inline[] | SORT _score DESC | LIMIT 10 | KEEP semantic_text_field diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java index c71646f3caf3a..dabb9c3262e6b 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java @@ -20,7 +20,6 @@ import org.elasticsearch.xpack.esql.expression.function.FunctionInfo; import org.elasticsearch.xpack.esql.expression.function.Param; -import java.io.IOException; import java.util.List; import java.util.Objects; @@ -40,14 +39,24 @@ public class TextEmbedding extends InferenceFunction { @FunctionInfo( returnType = "dense_vector", - description = "Generates dense vector embeddings for text using a specified inference endpoint.", + description = "Generates dense vector embeddings from a text using a specified inference endpoint.", appliesTo = { @FunctionAppliesTo(version = "9.3", lifeCycle = FunctionAppliesToLifecycle.PREVIEW) }, preview = true, examples = { @Example( description = "Generate text embeddings using the 'test_dense_inference' inference endpoint.", file = "text-embedding", - tag = "embedding-eval" + tag = "text-embedding-eval" + ), + @Example( + description = "Generate text embeddings for use within a KNN search.", + file = "text-embedding", + tag = "text-embedding-knn" + ), + @Example( + description = "Generate text embeddings inline within a KNN search.", + file = "text-embedding", + tag = "text-embedding-knn-inline" ) } ) public TextEmbedding( @@ -56,7 +65,7 @@ public TextEmbedding( @Param( name = InferenceFunction.INFERENCE_ID_PARAMETER_NAME, type = { "keyword" }, - description = "Identifier of the inference endpoint" + description = "Identifier of the inference endpoint. The inference endpoint must have the `text_embedding` task type." ) Expression inferenceId ) { super(source, List.of(inputText, inferenceId)); @@ -65,7 +74,7 @@ public TextEmbedding( } @Override - public void writeTo(StreamOutput out) throws IOException { + public void writeTo(StreamOutput out) { throw new UnsupportedOperationException("doesn't escape the node"); } From 142da3631afde14f5c1a667e386ec8ba1115362a Mon Sep 17 00:00:00 2001 From: afoucret Date: Tue, 7 Oct 2025 19:41:30 +0200 Subject: [PATCH 11/18] Fix typo in code. --- .../esql/_snippets/functions/examples/text_embedding.md | 3 ++- .../esql/kibana/definition/functions/text_embedding.json | 2 +- .../qa/testFixtures/src/main/resources/text-embedding.csv-spec | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md index 914ceb472b7da..459de67ba3a19 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md @@ -21,7 +21,8 @@ FROM semantic_text METADATA _score Generate text embeddings inline within a KNN search. ```esql -null +FROM semantic_text METADATA _score +| WHERE KNN(semantic_text_dense_field, TEXT_EMBEDDING("be excellent to each other", "test_dense_inference")) ``` diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json index ab0e17bfc256a..061c3aa4477bb 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json @@ -26,7 +26,7 @@ "examples" : [ "ROW input=\"Who is Victor Hugo?\"\n| EVAL embedding = TEXT_EMBEDDING(\"Who is Victor Hugo?\", \"test_dense_inference\")\n;", "FROM semantic_text METADATA _score\n| EVAL query_embedding = TEXT_EMBEDDING(\"be excellent to each other\", \"test_dense_inference\")\n| WHERE KNN(semantic_text_dense_field, query_embedding)", - null + "FROM semantic_text METADATA _score\n| WHERE KNN(semantic_text_dense_field, TEXT_EMBEDDING(\"be excellent to each other\", \"test_dense_inference\"))" ], "preview" : true, "snapshot_only" : false diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/text-embedding.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/text-embedding.csv-spec index c83adf4cc1580..9729a6f78f16c 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/text-embedding.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/text-embedding.csv-spec @@ -57,7 +57,7 @@ required_capability: semantic_text_field_caps // tag::text-embedding-knn-inline[] FROM semantic_text METADATA _score | WHERE KNN(semantic_text_dense_field, TEXT_EMBEDDING("be excellent to each other", "test_dense_inference")) -// end::text-text-embedding-knn-inline[] +// end::text-embedding-knn-inline[] | SORT _score DESC | LIMIT 10 | KEEP semantic_text_field From 78e22c30ee7e90d2442e2bbce655b25fbce02aa1 Mon Sep 17 00:00:00 2001 From: afoucret Date: Wed, 8 Oct 2025 10:51:12 +0200 Subject: [PATCH 12/18] Fix typo --- .../esql/_snippets/lists/dense-vector-functions.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md b/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md index 14f5365b4fc6e..2268dd649bba5 100644 --- a/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md +++ b/docs/reference/query-languages/esql/_snippets/lists/dense-vector-functions.md @@ -1,6 +1,5 @@ * {applies_to}`stack: preview 9.2` {applies_to}`serverless: preview` [`KNN`](../../functions-operators/dense-vector-functions.md#esql-knn) -* {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [ - `TEXT_EMBEDDING`](../../functions-operators/dense-vector-functions.md#esql-text_embedding) +* {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`TEXT_EMBEDDING`](../../functions-operators/dense-vector-functions.md#esql-text_embedding) % * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`V_COSINE`](../../functions-operators/dense-vector-functions.md#esql-v_cosine) % * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`V_DOT_PRODUCT`](../../functions-operators/dense-vector-functions.md#esql-v_dot_product) From 409be1f2eb391d5dcd30f5b56b72665bada49f55 Mon Sep 17 00:00:00 2001 From: afoucret Date: Wed, 8 Oct 2025 11:05:23 +0200 Subject: [PATCH 13/18] Improved doc for the TEXT_EMBEDDING function --- .../functions/description/text_embedding.md | 2 +- .../functions/examples/text_embedding.md | 17 +----------- .../functions/parameters/text_embedding.md | 4 +-- .../definition/functions/text_embedding.json | 10 +++---- .../kibana/docs/functions/text_embedding.md | 2 +- .../function/inference/TextEmbedding.java | 27 +++++++++---------- 6 files changed, 22 insertions(+), 40 deletions(-) diff --git a/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md index ae550ad09adc4..753cc984ddd1d 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md @@ -2,5 +2,5 @@ **Description** -Generates dense vector embeddings from a text using a specified inference endpoint. +Converts a constant text into dense vector embeddings using a inference endpoint. The resulting vectors can be used for knn search, and other vector-based operations. Requires an inference endpoint configured with the `text_embedding` task type. See [Inference API documentation] for how to create inference endpoints. diff --git a/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md index 459de67ba3a19..71d05c9524350 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md @@ -1,6 +1,6 @@ % This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it. -**Examples** +**Example** Generate text embeddings using the 'test_dense_inference' inference endpoint. @@ -10,19 +10,4 @@ ROW input="Who is Victor Hugo?" ; ``` -Generate text embeddings for use within a KNN search. - -```esql -FROM semantic_text METADATA _score -| EVAL query_embedding = TEXT_EMBEDDING("be excellent to each other", "test_dense_inference") -| WHERE KNN(semantic_text_dense_field, query_embedding) -``` - -Generate text embeddings inline within a KNN search. - -```esql -FROM semantic_text METADATA _score -| WHERE KNN(semantic_text_dense_field, TEXT_EMBEDDING("be excellent to each other", "test_dense_inference")) -``` - diff --git a/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md index 6c83af7412f12..a5fa1614c0504 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md @@ -3,8 +3,8 @@ **Parameters** `text` -: Text to generate embeddings from +: Text to generate embeddings from. Must be a non-null keyword constant. `inference_id` -: Identifier of the inference endpoint. The inference endpoint must have the `text_embedding` task type. +: Identifier of an existing inference endpoint the that will generate the embeddings. The inference endpoint must have the `text_embedding` task type. diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json index 061c3aa4477bb..2387cd880a6cc 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json @@ -2,7 +2,7 @@ "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.", "type" : "scalar", "name" : "text_embedding", - "description" : "Generates dense vector embeddings from a text using a specified inference endpoint.", + "description" : "Converts a constant text into dense vector embeddings using a inference endpoint. The resulting vectors can be used for knn search, and other vector-based operations. Requires an inference endpoint configured with the `text_embedding` task type. See [Inference API documentation] for how to create inference endpoints.", "signatures" : [ { "params" : [ @@ -10,13 +10,13 @@ "name" : "text", "type" : "keyword", "optional" : false, - "description" : "Text to generate embeddings from" + "description" : "Text to generate embeddings from. Must be a non-null keyword constant." }, { "name" : "inference_id", "type" : "keyword", "optional" : false, - "description" : "Identifier of the inference endpoint. The inference endpoint must have the `text_embedding` task type." + "description" : "Identifier of an existing inference endpoint the that will generate the embeddings. The inference endpoint must have the `text_embedding` task type." } ], "variadic" : false, @@ -24,9 +24,7 @@ } ], "examples" : [ - "ROW input=\"Who is Victor Hugo?\"\n| EVAL embedding = TEXT_EMBEDDING(\"Who is Victor Hugo?\", \"test_dense_inference\")\n;", - "FROM semantic_text METADATA _score\n| EVAL query_embedding = TEXT_EMBEDDING(\"be excellent to each other\", \"test_dense_inference\")\n| WHERE KNN(semantic_text_dense_field, query_embedding)", - "FROM semantic_text METADATA _score\n| WHERE KNN(semantic_text_dense_field, TEXT_EMBEDDING(\"be excellent to each other\", \"test_dense_inference\"))" + "ROW input=\"Who is Victor Hugo?\"\n| EVAL embedding = TEXT_EMBEDDING(\"Who is Victor Hugo?\", \"test_dense_inference\")\n;" ], "preview" : true, "snapshot_only" : false diff --git a/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md b/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md index 7d78c24384c62..4ceb8fbfba1fe 100644 --- a/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md +++ b/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md @@ -1,7 +1,7 @@ % This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it. ### TEXT EMBEDDING -Generates dense vector embeddings from a text using a specified inference endpoint. +Converts a constant text into dense vector embeddings using a inference endpoint. The resulting vectors can be used for knn search, and other vector-based operations. Requires an inference endpoint configured with the `text_embedding` task type. See [Inference API documentation] for how to create inference endpoints. ```esql ROW input="Who is Victor Hugo?" diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java index dabb9c3262e6b..1d8b88e4d20cb 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java @@ -20,6 +20,7 @@ import org.elasticsearch.xpack.esql.expression.function.FunctionInfo; import org.elasticsearch.xpack.esql.expression.function.Param; +import java.io.IOException; import java.util.List; import java.util.Objects; @@ -39,7 +40,10 @@ public class TextEmbedding extends InferenceFunction { @FunctionInfo( returnType = "dense_vector", - description = "Generates dense vector embeddings from a text using a specified inference endpoint.", + description = "Converts a constant text into dense vector embeddings using a inference endpoint. " + + "The resulting vectors can be used for knn search, and other vector-based operations. " + + "Requires an inference endpoint configured with the `text_embedding` task type. " + + " See [Inference API documentation] for how to create inference endpoints.", appliesTo = { @FunctionAppliesTo(version = "9.3", lifeCycle = FunctionAppliesToLifecycle.PREVIEW) }, preview = true, examples = { @@ -47,25 +51,20 @@ public class TextEmbedding extends InferenceFunction { description = "Generate text embeddings using the 'test_dense_inference' inference endpoint.", file = "text-embedding", tag = "text-embedding-eval" - ), - @Example( - description = "Generate text embeddings for use within a KNN search.", - file = "text-embedding", - tag = "text-embedding-knn" - ), - @Example( - description = "Generate text embeddings inline within a KNN search.", - file = "text-embedding", - tag = "text-embedding-knn-inline" ) } ) public TextEmbedding( Source source, - @Param(name = "text", type = { "keyword" }, description = "Text to generate embeddings from") Expression inputText, + @Param( + name = "text", + type = { "keyword" }, + description = "Text to generate embeddings from. Must be a non-null keyword constant." + ) Expression inputText, @Param( name = InferenceFunction.INFERENCE_ID_PARAMETER_NAME, type = { "keyword" }, - description = "Identifier of the inference endpoint. The inference endpoint must have the `text_embedding` task type." + description = "Identifier of an existing inference endpoint the that will generate the embeddings. " + + "The inference endpoint must have the `text_embedding` task type." ) Expression inferenceId ) { super(source, List.of(inputText, inferenceId)); @@ -74,7 +73,7 @@ public TextEmbedding( } @Override - public void writeTo(StreamOutput out) { + public void writeTo(StreamOutput out) throws IOException { throw new UnsupportedOperationException("doesn't escape the node"); } From 9c3db767759952a2c13ea08f5d55089abc5f4cc1 Mon Sep 17 00:00:00 2001 From: afoucret Date: Wed, 8 Oct 2025 11:10:38 +0200 Subject: [PATCH 14/18] Add missing link in the doc. --- .../esql/_snippets/functions/description/text_embedding.md | 2 +- .../esql/kibana/definition/functions/text_embedding.json | 2 +- .../esql/kibana/docs/functions/text_embedding.md | 2 +- .../esql/expression/function/inference/TextEmbedding.java | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md index 753cc984ddd1d..07689ca8ac4d9 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md @@ -2,5 +2,5 @@ **Description** -Converts a constant text into dense vector embeddings using a inference endpoint. The resulting vectors can be used for knn search, and other vector-based operations. Requires an inference endpoint configured with the `text_embedding` task type. See [Inference API documentation] for how to create inference endpoints. +Converts a constant text into dense vector embeddings using a inference endpoint. The resulting vectors can be used for knn search, and other vector-based operations. Requires an inference endpoint configured with the `text_embedding` task type. See [Inference API documentation](docs-content://explore-analyze/elastic-inference/inference-api.md) for how to create inference endpoints. diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json index 2387cd880a6cc..a9222529aadfc 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json @@ -2,7 +2,7 @@ "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.", "type" : "scalar", "name" : "text_embedding", - "description" : "Converts a constant text into dense vector embeddings using a inference endpoint. The resulting vectors can be used for knn search, and other vector-based operations. Requires an inference endpoint configured with the `text_embedding` task type. See [Inference API documentation] for how to create inference endpoints.", + "description" : "Converts a constant text into dense vector embeddings using a inference endpoint. The resulting vectors can be used for knn search, and other vector-based operations. Requires an inference endpoint configured with the `text_embedding` task type. See Inference API documentation for how to create inference endpoints.", "signatures" : [ { "params" : [ diff --git a/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md b/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md index 4ceb8fbfba1fe..edfdf01b92664 100644 --- a/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md +++ b/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md @@ -1,7 +1,7 @@ % This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it. ### TEXT EMBEDDING -Converts a constant text into dense vector embeddings using a inference endpoint. The resulting vectors can be used for knn search, and other vector-based operations. Requires an inference endpoint configured with the `text_embedding` task type. See [Inference API documentation] for how to create inference endpoints. +Converts a constant text into dense vector embeddings using a inference endpoint. The resulting vectors can be used for knn search, and other vector-based operations. Requires an inference endpoint configured with the `text_embedding` task type. See [Inference API documentation](docs-content://explore-analyze/elastic-inference/inference-api.md) for how to create inference endpoints. ```esql ROW input="Who is Victor Hugo?" diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java index 1d8b88e4d20cb..ecb8f92485148 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java @@ -43,7 +43,8 @@ public class TextEmbedding extends InferenceFunction { description = "Converts a constant text into dense vector embeddings using a inference endpoint. " + "The resulting vectors can be used for knn search, and other vector-based operations. " + "Requires an inference endpoint configured with the `text_embedding` task type. " - + " See [Inference API documentation] for how to create inference endpoints.", + + "See [Inference API documentation](docs-content://explore-analyze/elastic-inference/inference-api.md) " + + "for how to create inference endpoints.", appliesTo = { @FunctionAppliesTo(version = "9.3", lifeCycle = FunctionAppliesToLifecycle.PREVIEW) }, preview = true, examples = { From ea202ba6286a1a5de46d1b2a4dcd23831dccb0cb Mon Sep 17 00:00:00 2001 From: afoucret Date: Wed, 8 Oct 2025 11:21:28 +0200 Subject: [PATCH 15/18] Apply changes from review. --- .../functions/description/text_embedding.md | 2 +- .../_snippets/functions/examples/text_embedding.md | 1 - .../functions/parameters/text_embedding.md | 4 ++-- .../definition/functions/text_embedding.json | 8 ++++---- .../esql/kibana/docs/functions/text_embedding.md | 3 +-- .../src/main/resources/text-embedding.csv-spec | 2 +- .../function/inference/TextEmbedding.java | 14 +++++++------- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md index 07689ca8ac4d9..8090d4dd35794 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md @@ -2,5 +2,5 @@ **Description** -Converts a constant text into dense vector embeddings using a inference endpoint. The resulting vectors can be used for knn search, and other vector-based operations. Requires an inference endpoint configured with the `text_embedding` task type. See [Inference API documentation](docs-content://explore-analyze/elastic-inference/inference-api.md) for how to create inference endpoints. +Generates dense vector embeddings from text input using a specified [inference endpoint](docs-content://explore-analyze/elastic-inference/inference-api.md). Use this function to generate query vectors for KNN searches against your vectorized data or other dense vector based operations. diff --git a/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md index 71d05c9524350..13099f686c267 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md @@ -7,7 +7,6 @@ Generate text embeddings using the 'test_dense_inference' inference endpoint. ```esql ROW input="Who is Victor Hugo?" | EVAL embedding = TEXT_EMBEDDING("Who is Victor Hugo?", "test_dense_inference") -; ``` diff --git a/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md index a5fa1614c0504..f0a1b7bd3ae6b 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md @@ -3,8 +3,8 @@ **Parameters** `text` -: Text to generate embeddings from. Must be a non-null keyword constant. +: Text string to generate embeddings from. Must be a non-null keyword constant. `inference_id` -: Identifier of an existing inference endpoint the that will generate the embeddings. The inference endpoint must have the `text_embedding` task type. +: Identifier of an existing inference endpoint the that will generate the embeddings. The inference endpoint must have the `text_embedding` task type and should use the same model that was used to embed your indexed data. diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json index a9222529aadfc..31be3a06b8315 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json @@ -2,7 +2,7 @@ "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.", "type" : "scalar", "name" : "text_embedding", - "description" : "Converts a constant text into dense vector embeddings using a inference endpoint. The resulting vectors can be used for knn search, and other vector-based operations. Requires an inference endpoint configured with the `text_embedding` task type. See Inference API documentation for how to create inference endpoints.", + "description" : "Generates dense vector embeddings from text input using a specified inference endpoint. Use this function to generate query vectors for KNN searches against your vectorized data or other dense vector based operations.", "signatures" : [ { "params" : [ @@ -10,13 +10,13 @@ "name" : "text", "type" : "keyword", "optional" : false, - "description" : "Text to generate embeddings from. Must be a non-null keyword constant." + "description" : "Text string to generate embeddings from. Must be a non-null keyword constant." }, { "name" : "inference_id", "type" : "keyword", "optional" : false, - "description" : "Identifier of an existing inference endpoint the that will generate the embeddings. The inference endpoint must have the `text_embedding` task type." + "description" : "Identifier of an existing inference endpoint the that will generate the embeddings. The inference endpoint must have the `text_embedding` task type and should use the same model that was used to embed your indexed data." } ], "variadic" : false, @@ -24,7 +24,7 @@ } ], "examples" : [ - "ROW input=\"Who is Victor Hugo?\"\n| EVAL embedding = TEXT_EMBEDDING(\"Who is Victor Hugo?\", \"test_dense_inference\")\n;" + "ROW input=\"Who is Victor Hugo?\"\n| EVAL embedding = TEXT_EMBEDDING(\"Who is Victor Hugo?\", \"test_dense_inference\")" ], "preview" : true, "snapshot_only" : false diff --git a/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md b/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md index edfdf01b92664..99f87603df5f8 100644 --- a/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md +++ b/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md @@ -1,10 +1,9 @@ % This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it. ### TEXT EMBEDDING -Converts a constant text into dense vector embeddings using a inference endpoint. The resulting vectors can be used for knn search, and other vector-based operations. Requires an inference endpoint configured with the `text_embedding` task type. See [Inference API documentation](docs-content://explore-analyze/elastic-inference/inference-api.md) for how to create inference endpoints. +Generates dense vector embeddings from text input using a specified [inference endpoint](docs-content://explore-analyze/elastic-inference/inference-api.md). Use this function to generate query vectors for KNN searches against your vectorized data or other dense vector based operations. ```esql ROW input="Who is Victor Hugo?" | EVAL embedding = TEXT_EMBEDDING("Who is Victor Hugo?", "test_dense_inference") -; ``` diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/text-embedding.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/text-embedding.csv-spec index 9729a6f78f16c..002d39f767f85 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/text-embedding.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/text-embedding.csv-spec @@ -5,8 +5,8 @@ required_capability: dense_vector_field_type_released // tag::text-embedding-eval[] ROW input="Who is Victor Hugo?" | EVAL embedding = TEXT_EMBEDDING("Who is Victor Hugo?", "test_dense_inference") -; // end::text-embedding-eval[] +; input:keyword | embedding:dense_vector Who is Victor Hugo? | [56.0, 50.0, 48.0] diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java index ecb8f92485148..a0a6397c211dd 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java @@ -40,11 +40,10 @@ public class TextEmbedding extends InferenceFunction { @FunctionInfo( returnType = "dense_vector", - description = "Converts a constant text into dense vector embeddings using a inference endpoint. " - + "The resulting vectors can be used for knn search, and other vector-based operations. " - + "Requires an inference endpoint configured with the `text_embedding` task type. " - + "See [Inference API documentation](docs-content://explore-analyze/elastic-inference/inference-api.md) " - + "for how to create inference endpoints.", + description = "Generates dense vector embeddings from text input using a specified " + + "[inference endpoint](docs-content://explore-analyze/elastic-inference/inference-api.md). " + + "Use this function to generate query vectors for KNN searches against your vectorized data " + + "or other dense vector based operations.", appliesTo = { @FunctionAppliesTo(version = "9.3", lifeCycle = FunctionAppliesToLifecycle.PREVIEW) }, preview = true, examples = { @@ -59,13 +58,14 @@ public TextEmbedding( @Param( name = "text", type = { "keyword" }, - description = "Text to generate embeddings from. Must be a non-null keyword constant." + description = "Text string to generate embeddings from. Must be a non-null keyword constant." ) Expression inputText, @Param( name = InferenceFunction.INFERENCE_ID_PARAMETER_NAME, type = { "keyword" }, description = "Identifier of an existing inference endpoint the that will generate the embeddings. " - + "The inference endpoint must have the `text_embedding` task type." + + "The inference endpoint must have the `text_embedding` task type and should use the same model " + + "that was used to embed your indexed data." ) Expression inferenceId ) { super(source, List.of(inputText, inferenceId)); From 01f30211264b5a563fe91bd99e0dfaa7a8c350f3 Mon Sep 17 00:00:00 2001 From: afoucret Date: Wed, 8 Oct 2025 11:25:13 +0200 Subject: [PATCH 16/18] Restore missing examples. --- .../functions/examples/text_embedding.md | 17 ++++++++++++++++- .../definition/functions/text_embedding.json | 4 +++- .../function/inference/TextEmbedding.java | 10 ++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md index 13099f686c267..9b40c268c5f32 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md @@ -1,6 +1,6 @@ % This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it. -**Example** +**Examples** Generate text embeddings using the 'test_dense_inference' inference endpoint. @@ -9,4 +9,19 @@ ROW input="Who is Victor Hugo?" | EVAL embedding = TEXT_EMBEDDING("Who is Victor Hugo?", "test_dense_inference") ``` +Generate text embeddings for use within a KNN search. + +```esql +FROM semantic_text METADATA _score +| EVAL query_embedding = TEXT_EMBEDDING("be excellent to each other", "test_dense_inference") +| WHERE KNN(semantic_text_dense_field, query_embedding) +``` + +Generate text embeddings inline within a KNN search. + +```esql +FROM semantic_text METADATA _score +| WHERE KNN(semantic_text_dense_field, TEXT_EMBEDDING("be excellent to each other", "test_dense_inference")) +``` + diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json index 31be3a06b8315..7828ab45bf4e1 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json @@ -24,7 +24,9 @@ } ], "examples" : [ - "ROW input=\"Who is Victor Hugo?\"\n| EVAL embedding = TEXT_EMBEDDING(\"Who is Victor Hugo?\", \"test_dense_inference\")" + "ROW input=\"Who is Victor Hugo?\"\n| EVAL embedding = TEXT_EMBEDDING(\"Who is Victor Hugo?\", \"test_dense_inference\")", + "FROM semantic_text METADATA _score\n| EVAL query_embedding = TEXT_EMBEDDING(\"be excellent to each other\", \"test_dense_inference\")\n| WHERE KNN(semantic_text_dense_field, query_embedding)", + "FROM semantic_text METADATA _score\n| WHERE KNN(semantic_text_dense_field, TEXT_EMBEDDING(\"be excellent to each other\", \"test_dense_inference\"))" ], "preview" : true, "snapshot_only" : false diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java index a0a6397c211dd..42cf40e29f8b6 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java @@ -51,6 +51,16 @@ public class TextEmbedding extends InferenceFunction { description = "Generate text embeddings using the 'test_dense_inference' inference endpoint.", file = "text-embedding", tag = "text-embedding-eval" + ), + @Example( + description = "Generate text embeddings for use within a KNN search.", + file = "text-embedding", + tag = "text-embedding-knn" + ), + @Example( + description = "Generate text embeddings inline within a KNN search.", + file = "text-embedding", + tag = "text-embedding-knn-inline" ) } ) public TextEmbedding( From ce9580a9f84491cb4caae8bf8b8ba9ce1f5887e5 Mon Sep 17 00:00:00 2001 From: afoucret Date: Wed, 8 Oct 2025 11:29:33 +0200 Subject: [PATCH 17/18] Update examples descriptions. --- .../_snippets/functions/description/text_embedding.md | 2 +- .../esql/_snippets/functions/examples/text_embedding.md | 6 +++--- .../esql/kibana/definition/functions/text_embedding.json | 2 +- .../esql/kibana/docs/functions/text_embedding.md | 2 +- .../esql/expression/function/inference/TextEmbedding.java | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md index 8090d4dd35794..a737cd10bded8 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md @@ -2,5 +2,5 @@ **Description** -Generates dense vector embeddings from text input using a specified [inference endpoint](docs-content://explore-analyze/elastic-inference/inference-api.md). Use this function to generate query vectors for KNN searches against your vectorized data or other dense vector based operations. +Generates dense vector embeddings from text input using a specified [inference endpoint](docs-content://explore-analyze/elastic-inference/inference-api.md). Use this function to generate query vectors for KNN searches against your vectorized data or others dense vector based operations. diff --git a/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md index 9b40c268c5f32..a6384e1222891 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md @@ -2,14 +2,14 @@ **Examples** -Generate text embeddings using the 'test_dense_inference' inference endpoint. +Basic text embedding generation from a text string using an inference endpoint. ```esql ROW input="Who is Victor Hugo?" | EVAL embedding = TEXT_EMBEDDING("Who is Victor Hugo?", "test_dense_inference") ``` -Generate text embeddings for use within a KNN search. +Generate text embeddings and store them in a variable for reuse in KNN vector search queries. ```esql FROM semantic_text METADATA _score @@ -17,7 +17,7 @@ FROM semantic_text METADATA _score | WHERE KNN(semantic_text_dense_field, query_embedding) ``` -Generate text embeddings inline within a KNN search. +Directly embed text within a KNN query for streamlined vector search without intermediate variables. ```esql FROM semantic_text METADATA _score diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json index 7828ab45bf4e1..a32d17db8e877 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json @@ -2,7 +2,7 @@ "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.", "type" : "scalar", "name" : "text_embedding", - "description" : "Generates dense vector embeddings from text input using a specified inference endpoint. Use this function to generate query vectors for KNN searches against your vectorized data or other dense vector based operations.", + "description" : "Generates dense vector embeddings from text input using a specified inference endpoint. Use this function to generate query vectors for KNN searches against your vectorized data or others dense vector based operations.", "signatures" : [ { "params" : [ diff --git a/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md b/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md index 99f87603df5f8..a8ab12217608c 100644 --- a/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md +++ b/docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md @@ -1,7 +1,7 @@ % This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it. ### TEXT EMBEDDING -Generates dense vector embeddings from text input using a specified [inference endpoint](docs-content://explore-analyze/elastic-inference/inference-api.md). Use this function to generate query vectors for KNN searches against your vectorized data or other dense vector based operations. +Generates dense vector embeddings from text input using a specified [inference endpoint](docs-content://explore-analyze/elastic-inference/inference-api.md). Use this function to generate query vectors for KNN searches against your vectorized data or others dense vector based operations. ```esql ROW input="Who is Victor Hugo?" diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java index 42cf40e29f8b6..8125301ba0c41 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java @@ -43,22 +43,22 @@ public class TextEmbedding extends InferenceFunction { description = "Generates dense vector embeddings from text input using a specified " + "[inference endpoint](docs-content://explore-analyze/elastic-inference/inference-api.md). " + "Use this function to generate query vectors for KNN searches against your vectorized data " - + "or other dense vector based operations.", + + "or others dense vector based operations.", appliesTo = { @FunctionAppliesTo(version = "9.3", lifeCycle = FunctionAppliesToLifecycle.PREVIEW) }, preview = true, examples = { @Example( - description = "Generate text embeddings using the 'test_dense_inference' inference endpoint.", + description = "Basic text embedding generation from a text string using an inference endpoint.", file = "text-embedding", tag = "text-embedding-eval" ), @Example( - description = "Generate text embeddings for use within a KNN search.", + description = "Generate text embeddings and store them in a variable for reuse in KNN vector search queries.", file = "text-embedding", tag = "text-embedding-knn" ), @Example( - description = "Generate text embeddings inline within a KNN search.", + description = "Directly embed text within a KNN query for streamlined vector search without intermediate variables.", file = "text-embedding", tag = "text-embedding-knn-inline" ) } From 679d120bccbe7196715e8cbb37a4615e7e2b5453 Mon Sep 17 00:00:00 2001 From: afoucret Date: Wed, 8 Oct 2025 11:34:10 +0200 Subject: [PATCH 18/18] Few additional doc rework. --- .../esql/_snippets/functions/parameters/text_embedding.md | 2 +- .../esql/kibana/definition/functions/text_embedding.json | 2 +- .../xpack/esql/expression/function/inference/TextEmbedding.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md b/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md index f0a1b7bd3ae6b..9b7802b0f0db8 100644 --- a/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md +++ b/docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md @@ -3,7 +3,7 @@ **Parameters** `text` -: Text string to generate embeddings from. Must be a non-null keyword constant. +: Text string to generate embeddings from. Must be a non-null literal string value. `inference_id` : Identifier of an existing inference endpoint the that will generate the embeddings. The inference endpoint must have the `text_embedding` task type and should use the same model that was used to embed your indexed data. diff --git a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json index a32d17db8e877..f2c186a90cda7 100644 --- a/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json +++ b/docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json @@ -10,7 +10,7 @@ "name" : "text", "type" : "keyword", "optional" : false, - "description" : "Text string to generate embeddings from. Must be a non-null keyword constant." + "description" : "Text string to generate embeddings from. Must be a non-null literal string value." }, { "name" : "inference_id", diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java index 8125301ba0c41..65de2baf72a53 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java @@ -68,7 +68,7 @@ public TextEmbedding( @Param( name = "text", type = { "keyword" }, - description = "Text string to generate embeddings from. Must be a non-null keyword constant." + description = "Text string to generate embeddings from. Must be a non-null literal string value." ) Expression inputText, @Param( name = InferenceFunction.INFERENCE_ID_PARAMETER_NAME,