This is an automated email from the ASF dual-hosted git repository.
zclll pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push:
new 04d4531b187 add docs for
l2_distance_approximate/inner_product_approximate (#3180)
04d4531b187 is described below
commit 04d4531b187efc85db04c23dce50282fe265857a
Author: zhiqiang <[email protected]>
AuthorDate: Fri Dec 12 15:17:53 2025 +0800
add docs for l2_distance_approximate/inner_product_approximate (#3180)
## Versions
- [x] dev
- [x] 4.x
- [ ] 3.x
- [ ] 2.1
## Languages
- [x] Chinese
- [x] English
## Docs Checklist
- [ ] Checked by AI
- [ ] Test Cases Built
---
docs/ai/vector-search/overview.md | 4 +-
.../inner-product-approximate.md | 86 +++++++++++++++++++++
.../distance-functions/l2-distance-approximate.md | 86 +++++++++++++++++++++
.../current/ai/vector-search/overview.md | 4 +-
.../inner-product-approximate.md | 86 +++++++++++++++++++++
.../distance-functions/l2-distance-approximate.md | 86 +++++++++++++++++++++
.../version-4.x/ai/vector-search/overview.md | 4 +-
.../inner-product-approximate.md | 86 +++++++++++++++++++++
.../distance-functions/l2-distance-approximate.md | 86 +++++++++++++++++++++
static/images/vector-search/image.png | Bin 750864 -> 14695185
bytes
.../version-4.x/ai/vector-search/overview.md | 4 +-
11 files changed, 524 insertions(+), 8 deletions(-)
diff --git a/docs/ai/vector-search/overview.md
b/docs/ai/vector-search/overview.md
index 2f3fb6b817c..9147ef30b02 100644
--- a/docs/ai/vector-search/overview.md
+++ b/docs/ai/vector-search/overview.md
@@ -108,7 +108,7 @@ SELECT id,
embedding,
[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2]
) AS distance
-FROM sift_1m
+FROM sift_1M
ORDER BY distance
LIMIT 10;
--------------
@@ -151,7 +151,7 @@ Example SQL:
```sql
SELECT count(*)
-FROM sift_1m
+FROM sift_1M
WHERE l2_distance_approximate(
embedding,
[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2])
diff --git
a/docs/sql-manual/sql-functions/ai-functions/distance-functions/inner-product-approximate.md
b/docs/sql-manual/sql-functions/ai-functions/distance-functions/inner-product-approximate.md
new file mode 100644
index 00000000000..71adf96b212
--- /dev/null
+++
b/docs/sql-manual/sql-functions/ai-functions/distance-functions/inner-product-approximate.md
@@ -0,0 +1,86 @@
+---
+{
+ "title": "INNER_PRODUCT_APPROXIMATE",
+ "language": "en"
+}
+---
+
+## Description
+
+Approximate version of `inner_product`. If related array column has ann index
built on it, result of this function could be collected from index.
+
+## Syntax
+
+```sql
+INNER_PRODUCT_APPROXIMATE(<array1>, <array2>)
+```
+
+## Parameters
+
+| Parameter | Description |
+| -- |--|
+| `<array1>` | The first vector, the subtype of the input array supports:
TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, the number of elements
must be consistent with array2 |
+| `<array1>` | The second vector, the subtype of the input array supports:
TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, the number of elements
must be consistent with array1 |
+
+## Return Value
+
+Returns the scalar product of two vectors of the same size. If the input array
is NULL, or any element in array is NULL, then NULL is returned.
+
+## Examples
+
+```sql
+CREATE TABLE sift_1M (
+ id int NOT NULL,
+ embedding array<float> NOT NULL COMMENT "",
+ INDEX ann_index (embedding) USING ANN PROPERTIES(
+ "index_type"="hnsw",
+ "metric_type"="inner_product",
+ "dim"="128",
+ "quantizer"="flat"
+ )
+) ENGINE=OLAP
+DUPLICATE KEY(id) COMMENT "OLAP"
+DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES (
+ "replication_num" = "1"
+);
+```
+
+```sql
+INSERT INTO sift_1M
+SELECT *
+FROM S3(
+ "uri" =
"https://selectdb-customers-tools-bj.oss-cn-beijing.aliyuncs.com/sift_database.tsv",
+ "format" = "csv");
+```
+
+Do ann topn search that can be accelerated by ann index:
+
+```sql
+SELECT id,
+ L2_distance_approximate(embedding,
+[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2]
+) AS distance
+FROM sift_1M
+ORDER BY distance DESC
+LIMIT 10
+```
+Result
+
+```text
++--------+----------+
+| id | distance |
++--------+----------+
+| 178811 | 236430 |
+| 177646 | 234617 |
+| 181997 | 234301 |
+| 821938 | 234211 |
+| 181605 | 234026 |
+| 716433 | 232980 |
+| 807785 | 232551 |
+| 358802 | 232390 |
+| 279356 | 232177 |
+| 153488 | 231871 |
++--------+----------+
+10 rows in set (0.04 sec)
+```
diff --git
a/docs/sql-manual/sql-functions/ai-functions/distance-functions/l2-distance-approximate.md
b/docs/sql-manual/sql-functions/ai-functions/distance-functions/l2-distance-approximate.md
new file mode 100644
index 00000000000..3fe62602ae0
--- /dev/null
+++
b/docs/sql-manual/sql-functions/ai-functions/distance-functions/l2-distance-approximate.md
@@ -0,0 +1,86 @@
+---
+{
+ "title": "L2_DISTANCE_APPROXIMATE",
+ "language": "en"
+}
+---
+
+## Description
+
+Approximate version of `l2_distance`. If related array column has ann index
built on it, result of this function could be collected from index.
+
+## Syntax
+
+```sql
+L2_DISTANCE_APPROXIMATE(<array1>, <array2>)
+```
+
+## Parameters
+
+| Parameter | Description |
+| -- |--|
+| `<array1>` | The first vector (the vector value is the coordinate),The
subtypes of the input array are: TINYINT, SMALLINT, INT, BIGINT, LARGEINT,
FLOAT, DOUBLE, The number of elements must be consistent with array2 |
+| `<array2>` | The second vector (the vector value is the coordinate), the
subtype of the input array supports: TINYINT, SMALLINT, INT, BIGINT, LARGEINT,
FLOAT, DOUBLE, the number of elements must be consistent with array1 |
+
+## Return Value
+
+Returns the distance between two points (vector values are coordinates) in
Euclidean space. If the input array is NULL, or any element in the array is
NULL, then NULL is returned.
+
+## Example
+
+```sql
+CREATE TABLE sift_1M (
+ id int NOT NULL,
+ embedding array<float> NOT NULL COMMENT "",
+ INDEX ann_index (embedding) USING ANN PROPERTIES(
+ "index_type"="hnsw",
+ "metric_type"="l2_distance",
+ "dim"="128",
+ "quantizer"="flat"
+ )
+) ENGINE=OLAP
+DUPLICATE KEY(id) COMMENT "OLAP"
+DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES (
+ "replication_num" = "1"
+);
+```
+
+```sql
+INSERT INTO sift_1M
+SELECT *
+FROM S3(
+ "uri" =
"https://selectdb-customers-tools-bj.oss-cn-beijing.aliyuncs.com/sift_database.tsv",
+ "format" = "csv");
+```
+
+Do ann topn search that can be accelerated by ann index:
+
+```sql
+SELECT id,
+ L2_distance_approximate(embedding,
+[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2]
+) AS distance
+FROM sift_1M
+ORDER BY distance
+LIMIT 10
+```
+Result
+
+```text
++--------+----------+
+| id | distance |
++--------+----------+
+| 178811 | 210.1595 |
+| 177646 | 217.0161 |
+| 181997 | 218.5406 |
+| 181605 | 219.2989 |
+| 821938 | 221.7228 |
+| 807785 | 226.7135 |
+| 716433 | 227.3148 |
+| 358802 | 230.7314 |
+| 803100 | 230.9112 |
+| 866737 | 231.6441 |
++--------+----------+
+10 rows in set (0.08 sec)
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/ai/vector-search/overview.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/ai/vector-search/overview.md
index a7c8b6a5fe1..d99db337e03 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/ai/vector-search/overview.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/ai/vector-search/overview.md
@@ -101,7 +101,7 @@ SELECT id,
embedding,
[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2]
) AS distance
-FROM sift_1m
+FROM sift_1M
ORDER BY distance
LIMIT 10;
--------------
@@ -144,7 +144,7 @@ ANN 索引以 segment 为粒度构建。在分布式表中,每个 segment 返
```sql
SELECT count(*)
-FROM sift_1m
+FROM sift_1M
WHERE l2_distance_approximate(
embedding,
[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2])
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/ai-functions/distance-functions/inner-product-approximate.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/ai-functions/distance-functions/inner-product-approximate.md
new file mode 100644
index 00000000000..0fe6fd95b93
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/ai-functions/distance-functions/inner-product-approximate.md
@@ -0,0 +1,86 @@
+---
+{
+ "title": "INNER_PRODUCT_APPROXIMATE",
+ "language": "zh-CN"
+}
+---
+
+## 描述
+
+`inner_product` 的近似版本。如果相关的数组列在其上构建了 ANN 索引,则该函数的结果可以从索引中获取。
+
+## 语法
+
+```sql
+INNER_PRODUCT_APPROXIMATE(<array1>, <array2>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| -- |--|
+| `<array1>` |
第一个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素个数必须与
`array2` 一致 |
+| `<array2>` |
第二个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素个数必须与
`array1` 一致 |
+
+## 返回值
+
+返回两个相同大小向量的标量积。如果输入数组为 NULL,或数组中的任一元素为 NULL,则返回 NULL。
+
+## 示例
+
+```sql
+CREATE TABLE sift_1M (
+ id int NOT NULL,
+ embedding array<float> NOT NULL COMMENT "",
+ INDEX ann_index (embedding) USING ANN PROPERTIES(
+ "index_type"="hnsw",
+ "metric_type"="inner_product",
+ "dim"="128",
+ "quantizer"="flat"
+ )
+) ENGINE=OLAP
+DUPLICATE KEY(id) COMMENT "OLAP"
+DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES (
+ "replication_num" = "1"
+);
+```
+
+```sql
+INSERT INTO sift_1M
+SELECT *
+FROM S3(
+ "uri" =
"https://selectdb-customers-tools-bj.oss-cn-beijing.aliyuncs.com/sift_database.tsv",
+ "format" = "csv");
+```
+
+执行可由 ANN 索引加速的 topn 检索:
+
+```sql
+SELECT id,
+ L2_distance_approximate(embedding,
+[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2]
+) AS distance
+FROM sift_1M
+ORDER BY distance DESC
+LIMIT 10
+```
+结果:
+
+```text
++--------+----------+
+| id | distance |
++--------+----------+
+| 178811 | 236430 |
+| 177646 | 234617 |
+| 181997 | 234301 |
+| 821938 | 234211 |
+| 181605 | 234026 |
+| 716433 | 232980 |
+| 807785 | 232551 |
+| 358802 | 232390 |
+| 279356 | 232177 |
+| 153488 | 231871 |
++--------+----------+
+10 rows in set (0.04 sec)
+```
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/ai-functions/distance-functions/l2-distance-approximate.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/ai-functions/distance-functions/l2-distance-approximate.md
new file mode 100644
index 00000000000..f6fa26acc22
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/ai-functions/distance-functions/l2-distance-approximate.md
@@ -0,0 +1,86 @@
+---
+{
+ "title": "L2_DISTANCE_APPROXIMATE",
+ "language": "zh-CN"
+}
+---
+
+## 描述
+
+`l2_distance` 的近似版本。如果相关的数组列在其上构建了 ANN 索引,则该函数的结果可以从索引中获取。
+
+## 语法
+
+```sql
+L2_DISTANCE_APPROXIMATE(<array1>, <array2>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| -- |--|
+| `<array1>` |
第一个向量(向量值为坐标),输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素个数必须与
`array2` 一致 |
+| `<array2>` |
第二个向量(向量值为坐标),输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素个数必须与
`array1` 一致 |
+
+## 返回值
+
+返回欧氏空间中两个点(向量值为坐标)之间的距离。如果输入数组为 NULL,或数组中的任一元素为 NULL,则返回 NULL。
+
+## 示例
+
+```sql
+CREATE TABLE sift_1M (
+ id int NOT NULL,
+ embedding array<float> NOT NULL COMMENT "",
+ INDEX ann_index (embedding) USING ANN PROPERTIES(
+ "index_type"="hnsw",
+ "metric_type"="l2_distance",
+ "dim"="128",
+ "quantizer"="flat"
+ )
+) ENGINE=OLAP
+DUPLICATE KEY(id) COMMENT "OLAP"
+DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES (
+ "replication_num" = "1"
+);
+```
+
+```sql
+INSERT INTO sift_1M
+SELECT *
+FROM S3(
+ "uri" =
"https://selectdb-customers-tools-bj.oss-cn-beijing.aliyuncs.com/sift_database.tsv",
+ "format" = "csv");
+```
+
+执行可由 ANN 索引加速的 topn 检索:
+
+```sql
+SELECT id,
+ L2_distance_approximate(embedding,
+[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2]
+) AS distance
+FROM sift_1M
+ORDER BY distance
+LIMIT 10
+```
+结果:
+
+```text
++--------+----------+
+| id | distance |
++--------+----------+
+| 178811 | 210.1595 |
+| 177646 | 217.0161 |
+| 181997 | 218.5406 |
+| 181605 | 219.2989 |
+| 821938 | 221.7228 |
+| 807785 | 226.7135 |
+| 716433 | 227.3148 |
+| 358802 | 230.7314 |
+| 803100 | 230.9112 |
+| 866737 | 231.6441 |
++--------+----------+
+10 rows in set (0.08 sec)
+```
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/ai/vector-search/overview.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/ai/vector-search/overview.md
index 1bccdf35b66..6cce7382c57 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/ai/vector-search/overview.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/ai/vector-search/overview.md
@@ -101,7 +101,7 @@ SELECT id,
embedding,
[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2]
) AS distance
-FROM sift_1m
+FROM sift_1M
ORDER BY distance
LIMIT 10;
--------------
@@ -144,7 +144,7 @@ ANN 索引以 segment 为粒度构建。在分布式表中,每个 segment 返
```sql
SELECT count(*)
-FROM sift_1m
+FROM sift_1M
WHERE l2_distance_approximate(
embedding,
[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2])
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/ai-functions/distance-functions/inner-product-approximate.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/ai-functions/distance-functions/inner-product-approximate.md
new file mode 100644
index 00000000000..0fe6fd95b93
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/ai-functions/distance-functions/inner-product-approximate.md
@@ -0,0 +1,86 @@
+---
+{
+ "title": "INNER_PRODUCT_APPROXIMATE",
+ "language": "zh-CN"
+}
+---
+
+## 描述
+
+`inner_product` 的近似版本。如果相关的数组列在其上构建了 ANN 索引,则该函数的结果可以从索引中获取。
+
+## 语法
+
+```sql
+INNER_PRODUCT_APPROXIMATE(<array1>, <array2>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| -- |--|
+| `<array1>` |
第一个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素个数必须与
`array2` 一致 |
+| `<array2>` |
第二个向量,输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素个数必须与
`array1` 一致 |
+
+## 返回值
+
+返回两个相同大小向量的标量积。如果输入数组为 NULL,或数组中的任一元素为 NULL,则返回 NULL。
+
+## 示例
+
+```sql
+CREATE TABLE sift_1M (
+ id int NOT NULL,
+ embedding array<float> NOT NULL COMMENT "",
+ INDEX ann_index (embedding) USING ANN PROPERTIES(
+ "index_type"="hnsw",
+ "metric_type"="inner_product",
+ "dim"="128",
+ "quantizer"="flat"
+ )
+) ENGINE=OLAP
+DUPLICATE KEY(id) COMMENT "OLAP"
+DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES (
+ "replication_num" = "1"
+);
+```
+
+```sql
+INSERT INTO sift_1M
+SELECT *
+FROM S3(
+ "uri" =
"https://selectdb-customers-tools-bj.oss-cn-beijing.aliyuncs.com/sift_database.tsv",
+ "format" = "csv");
+```
+
+执行可由 ANN 索引加速的 topn 检索:
+
+```sql
+SELECT id,
+ L2_distance_approximate(embedding,
+[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2]
+) AS distance
+FROM sift_1M
+ORDER BY distance DESC
+LIMIT 10
+```
+结果:
+
+```text
++--------+----------+
+| id | distance |
++--------+----------+
+| 178811 | 236430 |
+| 177646 | 234617 |
+| 181997 | 234301 |
+| 821938 | 234211 |
+| 181605 | 234026 |
+| 716433 | 232980 |
+| 807785 | 232551 |
+| 358802 | 232390 |
+| 279356 | 232177 |
+| 153488 | 231871 |
++--------+----------+
+10 rows in set (0.04 sec)
+```
\ No newline at end of file
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/ai-functions/distance-functions/l2-distance-approximate.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/ai-functions/distance-functions/l2-distance-approximate.md
new file mode 100644
index 00000000000..f6fa26acc22
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/ai-functions/distance-functions/l2-distance-approximate.md
@@ -0,0 +1,86 @@
+---
+{
+ "title": "L2_DISTANCE_APPROXIMATE",
+ "language": "zh-CN"
+}
+---
+
+## 描述
+
+`l2_distance` 的近似版本。如果相关的数组列在其上构建了 ANN 索引,则该函数的结果可以从索引中获取。
+
+## 语法
+
+```sql
+L2_DISTANCE_APPROXIMATE(<array1>, <array2>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| -- |--|
+| `<array1>` |
第一个向量(向量值为坐标),输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素个数必须与
`array2` 一致 |
+| `<array2>` |
第二个向量(向量值为坐标),输入数组的子类型支持:TINYINT、SMALLINT、INT、BIGINT、LARGEINT、FLOAT、DOUBLE,元素个数必须与
`array1` 一致 |
+
+## 返回值
+
+返回欧氏空间中两个点(向量值为坐标)之间的距离。如果输入数组为 NULL,或数组中的任一元素为 NULL,则返回 NULL。
+
+## 示例
+
+```sql
+CREATE TABLE sift_1M (
+ id int NOT NULL,
+ embedding array<float> NOT NULL COMMENT "",
+ INDEX ann_index (embedding) USING ANN PROPERTIES(
+ "index_type"="hnsw",
+ "metric_type"="l2_distance",
+ "dim"="128",
+ "quantizer"="flat"
+ )
+) ENGINE=OLAP
+DUPLICATE KEY(id) COMMENT "OLAP"
+DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES (
+ "replication_num" = "1"
+);
+```
+
+```sql
+INSERT INTO sift_1M
+SELECT *
+FROM S3(
+ "uri" =
"https://selectdb-customers-tools-bj.oss-cn-beijing.aliyuncs.com/sift_database.tsv",
+ "format" = "csv");
+```
+
+执行可由 ANN 索引加速的 topn 检索:
+
+```sql
+SELECT id,
+ L2_distance_approximate(embedding,
+[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2]
+) AS distance
+FROM sift_1M
+ORDER BY distance
+LIMIT 10
+```
+结果:
+
+```text
++--------+----------+
+| id | distance |
++--------+----------+
+| 178811 | 210.1595 |
+| 177646 | 217.0161 |
+| 181997 | 218.5406 |
+| 181605 | 219.2989 |
+| 821938 | 221.7228 |
+| 807785 | 226.7135 |
+| 716433 | 227.3148 |
+| 358802 | 230.7314 |
+| 803100 | 230.9112 |
+| 866737 | 231.6441 |
++--------+----------+
+10 rows in set (0.08 sec)
+```
\ No newline at end of file
diff --git a/static/images/vector-search/image.png
b/static/images/vector-search/image.png
index 069a4c5099c..a665ff1aee2 100644
Binary files a/static/images/vector-search/image.png and
b/static/images/vector-search/image.png differ
diff --git a/versioned_docs/version-4.x/ai/vector-search/overview.md
b/versioned_docs/version-4.x/ai/vector-search/overview.md
index 4a35528df09..644b75b5698 100644
--- a/versioned_docs/version-4.x/ai/vector-search/overview.md
+++ b/versioned_docs/version-4.x/ai/vector-search/overview.md
@@ -108,7 +108,7 @@ SELECT id,
embedding,
[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2]
) AS distance
-FROM sift_1m
+FROM sift_1M
ORDER BY distance
LIMIT 10;
--------------
@@ -152,7 +152,7 @@ Example SQL:
```sql
SELECT count(*)
-FROM sift_1m
+FROM sift_1M
WHERE l2_distance_approximate(
embedding,
[0,11,77,24,3,0,0,0,28,70,125,8,0,0,0,0,44,35,50,45,9,0,0,0,4,0,4,56,18,0,3,9,16,17,59,10,10,8,57,57,100,105,125,41,1,0,6,92,8,14,73,125,29,7,0,5,0,0,8,124,66,6,3,1,63,5,0,1,49,32,17,35,125,21,0,3,2,12,6,109,21,0,0,35,74,125,14,23,0,0,6,50,25,70,64,7,59,18,7,16,22,5,0,1,125,23,1,0,7,30,14,32,4,0,2,2,59,125,19,4,0,0,2,1,6,53,33,2])
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]