Skip to content

Commit 8028218

Browse files
authored
[ES\QL] Add a section for vector functions in the doc. (#136077)
1 parent a7efa91 commit 8028218

File tree

9 files changed

+85
-10
lines changed

9 files changed

+85
-10
lines changed

docs/reference/query-languages/esql/_snippets/functions/layout/knn.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/parameters/knn.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.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* {applies_to}`stack: preview 9.2` {applies_to}`serverless: preview` [`KNN`](../../functions-operators/dense-vector-functions.md#esql-knn)
2+
3+
% * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`V_COSINE`](../../functions-operators/dense-vector-functions.md#esql-v_cosine)
4+
% * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`V_DOT_PRODUCT`](../../functions-operators/dense-vector-functions.md#esql-v_dot_product)
5+
% * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview`[`V_HAMMING`](../../functions-operators/dense-vector-functions.md#esql-v_hamming)
6+
% * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`V_L1_NORM`](../../functions-operators/dense-vector-functions.md#esql-v_l1_norm)
7+
% * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`V_L2_NORM`](../../functions-operators/dense-vector-functions.md#esql-v_l2_norm)
8+
% * {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview` [`V_MAGNITUDE`](../../functions-operators/dense-vector-functions.md#esql-v_magnitude)

docs/reference/query-languages/esql/esql-functions-operators.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ mapped_pages:
8080
:::
8181
::::
8282

83+
::::{dropdown} Dense vector functions
84+
:open:
85+
:::{include} _snippets/lists/dense-vector-functions.md
86+
:::
87+
::::
88+
8389
::::{dropdown} Multi value functions
8490
:open:
8591
:::{include} _snippets/lists/mv-functions.md
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
applies_to:
3+
stack: preview
4+
serverless: preview
5+
navigation_title: "Dense vector functions"
6+
mapped_pages:
7+
- https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-functions-operators.html#esql-dense-vector-functions
8+
---
9+
10+
# {{esql}} dense vector functions [esql-dense-vector-functions]
11+
12+
{{esql}} supports dense vector functions for vector similarity calculations and
13+
k-nearest neighbor search.
14+
Dsense vector functions work with [
15+
`dense_vector` fields](/reference/elasticsearch/mapping-reference/dense-vector.md)
16+
and require appropriate field mappings.
17+
18+
{{esql}} supports these vector functions:
19+
20+
:::{include} ../_snippets/lists/dense-vector-functions.md
21+
:::
22+
23+
:::{include} ../_snippets/functions/layout/knn.md
24+
:::
25+
26+
% V_COSINE is currently a hidden feature
27+
% To make it visible again, uncomment this and the line in
28+
% lists/dense-vector-functions.md
29+
% :::{include} ../_snippets/functions/layout/v_cosine.md
30+
% :::
31+
32+
% V_DOT_PRODUCT is currently a hidden feature
33+
% To make it visible again, uncomment this and the line in
34+
% lists/dense-vector-functions.md
35+
% :::{include} ../_snippets/functions/layout/v_dot_product.md
36+
% :::
37+
38+
% V_HAMMING is currently a hidden feature
39+
% To make it visible again, uncomment this and the line in
40+
% lists/dense-vector-functions.md
41+
% :::{include} ../_snippets/functions/layout/v_hamming.md
42+
% :::
43+
44+
% V_L1_NORM is currently a hidden feature
45+
% To make it visible again, uncomment this and the line in
46+
% lists/dense-vector-functions.md
47+
% :::{include} ../_snippets/functions/layout/v_l1_norm.md
48+
% :::
49+
50+
% V_L2_NORM is currently a hidden feature
51+
% To make it visible again, uncomment this and the line in
52+
% lists/dense-vector-functions.md
53+
% :::{include} ../_snippets/functions/layout/v_l2_norm.md
54+
% :::
55+
56+
% V_MAGNITUDE is currently a hidden feature
57+
% To make it visible again, uncomment this and the line in
58+
% lists/dense-vector-functions.md
59+
% :::{include} ../_snippets/functions/layout/v_magnitude.md
60+
% :::

docs/reference/query-languages/esql/functions-operators/search-functions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ Get started with {{esql}} for search use cases with
1414
our [hands-on tutorial](/reference/query-languages/esql/esql-search-tutorial.md).
1515

1616
For a high-level overview of search functionalities in {{esql}}, and to learn about relevance scoring, refer to [{{esql}} for search](docs-content://solutions/search/esql-for-search.md#esql-for-search-scoring).
17-
:::
1817

19-
{{esql}} provides a set of functions for performing searching on text fields.
18+
For information regarding dense vector search functions,
19+
including [KNN](dense-vector-functions.md#esql-knn), please refer to
20+
the [Dense vector functions](dense-vector-functions.md) documentation.
21+
:::
2022

21-
Use these functions
22-
for [full-text search](docs-content://solutions/search/full-text.md)
2323
and [semantic search](docs-content://solutions/search/semantic-search/semantic-search-semantic-text.md).
2424

2525
Full text functions can be used to

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

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

docs/reference/query-languages/toc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ toc:
133133
- file: esql/functions-operators/search-functions.md
134134
- file: esql/functions-operators/spatial-functions.md
135135
- file: esql/functions-operators/string-functions.md
136+
- file: esql/functions-operators/dense-vector-functions.md
136137
- file: esql/functions-operators/type-conversion-functions.md
137138
- file: esql/functions-operators/mv-functions.md
138139
- file: esql/functions-operators/operators.md

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/vector/Knn.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public class Knn extends FullTextFunction
103103
description = "Finds the k nearest vectors to a query vector, as measured by a similarity metric. "
104104
+ "knn function finds nearest vectors through approximate search on indexed dense_vectors or semantic_text fields.",
105105
examples = { @Example(file = "knn-function", tag = "knn-function") },
106-
appliesTo = { @FunctionAppliesTo(lifeCycle = FunctionAppliesToLifecycle.PREVIEW) }
106+
appliesTo = { @FunctionAppliesTo(lifeCycle = FunctionAppliesToLifecycle.PREVIEW, version = "9.2.0") }
107107
)
108108
public Knn(
109109
Source source,
@@ -153,7 +153,7 @@ public Knn(
153153
+ "(docs-content://solutions/search/vector/knn.md#dense-vector-knn-search-rescoring) for details."
154154
), },
155155
description = "(Optional) kNN additional options as <<esql-function-named-params,function named parameters>>."
156-
+ " See <<query-dsl-knn-query,knn query>> for more information.",
156+
+ " See [knn query](/reference/query-languages/query-dsl/query-dsl-knn-query.md) for more information.",
157157
optional = true
158158
) Expression options
159159
) {

0 commit comments

Comments
 (0)