You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|**`spatial_expr_1`**| An array of `float32` or smaller.|
36
-
|**`spatial_expr_2`**| An array of `float32` or smaller.|
37
-
|**`bool_expr`**| A boolean specifying how the computed value is used in an ORDER BY expression. If `true`, then brute force is used. A value of `false`leverages any index defined on the vector property, if it exists. Default value is `false`.|
38
-
|**`obj_expr`**| A JSON formatted object literal used to specify options for the vector distance calculation. Valid items include `distanceFunction` and `dataType`.|
39
-
| **`distanceFunction`** | The metric used to compute distance/similarity.
35
+
|**`spatial_expr_1`**| An array of `float32` or smaller.|
36
+
|**`spatial_expr_2`**| An array of `float32` or smaller.|
37
+
|**`bool_expr`**| A boolean specifying how the computed value is used in an ORDER BY expression. If `true`, then brute force is used. A value of `false`uses any index defined on the vector property, if it exists. Default value is `false`.|
38
+
|**`obj_expr`**| A JSON formatted object literal used to specify options for the vector distance calculation. Valid items include `distanceFunction` and `dataType`.|
39
+
|**`distanceFunction`**| The metric used to compute distance/similarity.|
40
40
|**`dataType`**| The data type of the vectors. `float32`, `int8`, `uint8` values. Default value is `float32`. |
41
41
42
+
Supported metrics for `distanceFunction` are:
42
43
43
-
Supported metrics for `distanceFunction` are:
44
-
*[cosine](https://en.wikipedia.org/wiki/Cosine_similarity), which has values from -1 (least similar) to +1 (most similar).
45
-
*[dotproduct](https://en.wikipedia.org/wiki/Dot_product), which has values from -inf (least similar) to +inf (most similar).
46
-
*[euclidean](https://en.wikipedia.org/wiki/Euclidean_distance), which has values from 0 (most similar) to +inf (least similar).
44
+
-[`cosine`](https://en.wikipedia.org/wiki/Cosine_similarity), which has values from `-1` (least similar) to `+1` (most similar).
45
+
-[`dotproduct`](https://en.wikipedia.org/wiki/Dot_product), which has values from `-∞` (`-inf`) (least similar) to `+∞` (`+inf`) (most similar).
46
+
-[`euclidean`](https://en.wikipedia.org/wiki/Euclidean_distance), which has values from `0` (most similar) to `+∞` (`+inf`) (least similar).
47
47
48
48
## Return types
49
49
50
50
Returns a numeric expression that enumerates the similarity score between two expressions.
51
51
52
52
## Examples
53
53
54
-
### With required arguments
54
+
This first example includes only the required arguments.
55
+
55
56
```sql
56
-
SELECTc.name, VectorDistance(c.vector1, c.vector2) AS SimilarityScore
- This function requires enrollment in the [Azure Cosmos DB NoSQL Vector Search preview feature](../vector-search.md#enroll-in-the-vector-search-preview-feature).
70
83
- This function benefits from a [vector index](../../index-policy.md#vector-indexes)
71
-
- if `false` is given as the optional `bool_expr`, then the vector index defined on the path is used, if one exists. If no index is defined on the vector path, then this reverts to full scan and incurs higher RU charges and higher latency than if using a vector index.
84
+
- if `false` is given as the optional `bool_expr`, then the vector index defined on the path is used, if one exists. If no index is defined on the vector path, then this function reverts to full scan and incurs higher RU charges and higher latency than if using a vector index.
72
85
- When `VectorDistance` is used in an `ORDER BY` clause, no direction needs to be specified for the `ORDER BY` as the results are always sorted in order of most similar (first) to least similar (last) based on the similarity metric used.
73
86
- The result is expressed as a similarity score.
74
87
75
88
## Related content
89
+
76
90
-[System functions](system-functions.yml)
77
91
-[Setup Azure Cosmos DB for NoSQL for vector search](../vector-search.md).
0 commit comments