Skip to content

Commit 6803a51

Browse files
committed
Update examples.
1 parent 7349c88 commit 6803a51

File tree

7 files changed

+43
-14
lines changed

7 files changed

+43
-14
lines changed

docs/reference/query-languages/esql/_snippets/functions/description/text_embedding.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/_snippets/functions/examples/text_embedding.md

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/_snippets/functions/parameters/text_embedding.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/definition/functions/text_embedding.json

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/docs/functions/text_embedding.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/qa/testFixtures/src/main/resources/text-embedding.csv-spec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ text_embedding using a row source operator
22
required_capability: text_embedding_function
33
required_capability: dense_vector_field_type_released
44

5-
// tag::embedding-eval[]
5+
// tag::text-embedding-eval[]
66
ROW input="Who is Victor Hugo?"
77
| EVAL embedding = TEXT_EMBEDDING("Who is Victor Hugo?", "test_dense_inference")
88
;
9-
// end::embedding-eval[]
9+
// end::text-embedding-eval[]
1010

1111
input:keyword | embedding:dense_vector
1212
Who is Victor Hugo? | [56.0, 50.0, 48.0]
@@ -32,9 +32,11 @@ required_capability: dense_vector_field_type_released
3232
required_capability: knn_function_v5
3333
required_capability: semantic_text_field_caps
3434

35+
// tag::text-embedding-knn[]
3536
FROM semantic_text METADATA _score
3637
| EVAL query_embedding = TEXT_EMBEDDING("be excellent to each other", "test_dense_inference")
3738
| WHERE KNN(semantic_text_dense_field, query_embedding)
39+
// end::text-embedding-knn[]
3840
| SORT _score DESC
3941
| LIMIT 10
4042
| KEEP semantic_text_field, query_embedding
@@ -52,8 +54,10 @@ required_capability: dense_vector_field_type_released
5254
required_capability: knn_function_v5
5355
required_capability: semantic_text_field_caps
5456

57+
// tag::text-embedding-knn-inline[]
5558
FROM semantic_text METADATA _score
5659
| WHERE KNN(semantic_text_dense_field, TEXT_EMBEDDING("be excellent to each other", "test_dense_inference"))
60+
// end::text-text-embedding-knn-inline[]
5761
| SORT _score DESC
5862
| LIMIT 10
5963
| KEEP semantic_text_field

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/inference/TextEmbedding.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
2121
import org.elasticsearch.xpack.esql.expression.function.Param;
2222

23-
import java.io.IOException;
2423
import java.util.List;
2524
import java.util.Objects;
2625

@@ -40,14 +39,24 @@ public class TextEmbedding extends InferenceFunction<TextEmbedding> {
4039

4140
@FunctionInfo(
4241
returnType = "dense_vector",
43-
description = "Generates dense vector embeddings for text using a specified inference endpoint.",
42+
description = "Generates dense vector embeddings from a text using a specified inference endpoint.",
4443
appliesTo = { @FunctionAppliesTo(version = "9.3", lifeCycle = FunctionAppliesToLifecycle.PREVIEW) },
4544
preview = true,
4645
examples = {
4746
@Example(
4847
description = "Generate text embeddings using the 'test_dense_inference' inference endpoint.",
4948
file = "text-embedding",
50-
tag = "embedding-eval"
49+
tag = "text-embedding-eval"
50+
),
51+
@Example(
52+
description = "Generate text embeddings for use within a KNN search.",
53+
file = "text-embedding",
54+
tag = "text-embedding-knn"
55+
),
56+
@Example(
57+
description = "Generate text embeddings inline within a KNN search.",
58+
file = "text-embedding",
59+
tag = "text-embedding-knn-inline"
5160
) }
5261
)
5362
public TextEmbedding(
@@ -56,7 +65,7 @@ public TextEmbedding(
5665
@Param(
5766
name = InferenceFunction.INFERENCE_ID_PARAMETER_NAME,
5867
type = { "keyword" },
59-
description = "Identifier of the inference endpoint"
68+
description = "Identifier of the inference endpoint. The inference endpoint must have the `text_embedding` task type."
6069
) Expression inferenceId
6170
) {
6271
super(source, List.of(inputText, inferenceId));
@@ -65,7 +74,7 @@ public TextEmbedding(
6574
}
6675

6776
@Override
68-
public void writeTo(StreamOutput out) throws IOException {
77+
public void writeTo(StreamOutput out) {
6978
throw new UnsupportedOperationException("doesn't escape the node");
7079
}
7180

0 commit comments

Comments
 (0)