Skip to content

Commit 08364ee

Browse files
committed
Generate docs for function
1 parent 312a727 commit 08364ee

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

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

Lines changed: 3 additions & 0 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/v_cosine.md

Lines changed: 7 additions & 0 deletions
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/vector-cosine-similarity.csv-spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
similarityWithVectorField
44
required_capability: cosine_vector_similarity_function
55

6+
// tag::vector-cosine-similarity[]
67
from colors
78
| where color != "black"
8-
| eval similarity = round(v_cosine(rgb_vector, [0, 255, 255]), 3)
9+
| eval similarity = v_cosine(rgb_vector, [0, 255, 255])
910
| sort similarity desc, color asc
11+
// end::vector-cosine-similarity[]
1012
| limit 10
1113
| keep color, similarity
1214
;
1315

16+
// tag::vector-cosine-similarity-result[]
1417
color:text | similarity:double
1518
cyan | 1.0
1619
teal | 1.0
@@ -22,6 +25,7 @@ honeydew | 0.912
2225
mint cream | 0.912
2326
gainsboro | 0.908
2427
gray | 0.908
28+
// end::vector-cosine-similarity-result[]
2529
;
2630

2731
similarityAsPartOfExpression

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.elasticsearch.xpack.esql.core.expression.function.scalar.BinaryScalarFunction;
1414
import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
1515
import org.elasticsearch.xpack.esql.core.tree.Source;
16+
import org.elasticsearch.xpack.esql.expression.function.Example;
1617
import org.elasticsearch.xpack.esql.expression.function.FunctionAppliesTo;
1718
import org.elasticsearch.xpack.esql.expression.function.FunctionAppliesToLifecycle;
1819
import org.elasticsearch.xpack.esql.expression.function.FunctionInfo;
@@ -35,6 +36,7 @@ public class CosineSimilarity extends VectorSimilarityFunction {
3536
returnType = "double",
3637
preview = true,
3738
description = "Calculates the cosine similarity between two dense_vectors.",
39+
examples = { @Example(file = "vector-cosine-similarity", tag = "vector-cosine-similarity") },
3840
appliesTo = { @FunctionAppliesTo(lifeCycle = FunctionAppliesToLifecycle.DEVELOPMENT) }
3941
)
4042
public CosineSimilarity(

0 commit comments

Comments
 (0)