文章目录
- 一、测试环境
- 二、代码
- 1、创建包含DenseVector的索引
- 2、索引文档
- 3、对向量字段进行近似knn检索
- 三、参考
一、测试环境
Elastic.Clients.Elasticsearch版本:8.13.0
Elasticsearch版本:8.13.0
二、代码
1、创建包含DenseVector的索引
public static bool InitIndex()
{// 定义索引配置var faceVectorproperties = new Properties{{ "Id" ,new KeywordProperty()},{ "FileID" ,new KeywordProperty()},{ "FileGUID" ,new KeywordProperty()},{ "ResourceID" ,new KeywordProperty()},{ "FileName" ,new TextProperty()},{ "Embedding" ,new DenseVectorProperty{Dims = 3 } }};// 定义索引配置var indexConfig = new IndexState{Settings