本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
(預覽) 使用 Amazon S3 向量引擎的進階搜尋功能
重要
Amazon S3 Vectors 與 OpenSearch Service 的整合處於預覽版本中,可能會有所變更。
Amazon OpenSearch Service 提供使用 Amazon S3 作為向量索引向量引擎的功能。此功能可讓您將向量資料卸載至 Amazon S3,同時以低成本維持低於一秒的向量搜尋功能。
透過此功能,OpenSearch 會將向量內嵌存放在 Amazon S3 向量索引中,同時將其他文件欄位保留在 OpenSearch 叢集的儲存中。此架構提供下列優點:
-
耐用性:寫入 S3 Vectors 的資料存放在 S3 上,專為 11 9 秒的資料耐用性而設計。
-
可擴展性:將大型向量資料集卸載至 S3,而不耗用叢集儲存。
-
成本效益:最佳化大量向量工作負載的儲存成本。
OpenSearch 有下列使用 S3 向量索引的需求:
-
OpenSearch 2.19 版或更新版本
-
OpenSearch Optimized 執行個體
-
OpenSearch 版本的最新修補程式版本
啟用 S3 向量
建立新網域或更新現有網域時,您可以在進階功能區段中選擇啟用 S3 向量作為引擎選項。當您利用 S3 向量做為引擎時,此設定可讓 OpenSearch 建立 S3 向量儲存貯體。當您啟用此選項時,OpenSearch 會透過下列方式為您的網域設定 S3 向量:
-
在以您的網域設定的 AWS KMS 金鑰上建立新的兩個授權:
-
授予具有解密權限的 S3 Vectors 背景索引任務
-
授予 OpenSearch 以建立具有
GenerateDataKey
許可的 S3 向量儲存貯體
-
-
將 OpenSearch 網域使用的 KMS 金鑰設定為所有向量索引資料其餘部分的加密 CMK。
使用 S3 向量引擎建立索引
設定網域之後,您可以使用 s3vector
做為索引映射中的後端向量引擎,以 欄位建立一或多個 k-NN 索引。您可以根據您的使用案例,使用不同的引擎類型來設定不同的向量欄位。
重要
您只能在建立索引期間使用s3vector
引擎對應欄位定義。建立索引後,您無法使用s3vector
引擎新增或更新映射。
以下是一些建立 S3 向量引擎索引的範例。
範例:使用 S3 向量引擎建立 k-NN 索引
PUT my-first-s3vector-index { "settings": { "index": { "knn": true } }, "mappings": { "properties": { "my_vector_1": { "type": "knn_vector", "dimension": 2, "space_type": "l2", "method": { "engine": "s3vector" } }, "price": { "type": "float" } } } }
範例:使用 S3 向量和 FAISS 引擎建立 k-NN 索引
此範例強調您可以在同一索引內使用多個向量引擎的事實。
PUT my-vector-index { "settings": { "index": { "knn": true } }, "mappings": { "properties": { "my_vector_1": { "type": "knn_vector", "dimension": 2, "space_type": "l2", "method": { "engine": "s3vector" } }, "price": { "type": "float" }, "my_vector_2": { "type": "knn_vector", "dimension": 2, "space_type": "cosine", "method": { "name": "hnsw", "engine": "faiss", "parameters": { "ef_construction": 128, "m": 24 } } } } } }
不支援的範例:建立索引後新增 S3 向量引擎
不支援下列方法,且 將會失敗。
PUT my-first-s3vector-index { "settings": { "index": { "knn": true } } } PUT my-first-s3vector-index/_mapping { "properties": { "my_vector_1": { "type": "knn_vector", "dimension": 2, "space_type": "l2", "method": { "engine": "s3vector" } }, "price": { "type": "float" } } }
功能限制
在索引中使用s3vector
引擎之前,請考慮下列限制:
功能 | Behavior (行為) |
---|---|
Split/Shrink/Clone索引 |
這些 APIs與 |
快照 |
使用
注意雖然快照不支援point-in-time復原,但 |
UltraWarm 層 |
使用 |
跨叢集複寫 |
使用 |
意外刪除保護 |
由於使用 |
放射搜尋 |
使用 |
索引文件
使用 S3 向量引擎建立索引後,您可以使用標準 _bulk
API 擷取文件。OpenSearch 會自動使用s3vector
引擎將knn_vector
欄位的向量資料即時卸載至 S3 向量索引。OpenSearch 會在自己的儲存層中保留屬於其他欄位或使用不同引擎knn_vector
的欄位的資料。
對於所有已確認的大量請求,OpenSearch 保證所有資料 (向量和非向量) 都耐用。如果請求收到負面確認,則無法保證該大量請求中文件的耐久性。您應該重試此類請求。
大量編製索引的範例
POST _bulk { "index": { "_index": "my-first-s3vector-index", "_id": "1" } } { "my_vector_1": [1.5, 2.5], "price": 12.2 } { "index": { "_index": "my-first-s3vector-index", "_id": "2" } } { "my_vector_1": [2.5, 3.5], "price": 7.1 } { "index": { "_index": "my-first-s3vector-index", "_id": "3" } } { "my_vector_1": [3.5, 4.5], "price": 12.9 } { "index": { "_index": "my-first-s3vector-index", "_id": "4" } } { "my_vector_1": [5.5, 6.5], "price": 1.2 } { "index": { "_index": "my-first-s3vector-index", "_id": "5" } } { "my_vector_1": [4.5, 5.5], "price": 3.7 }
搜尋文件
您可以使用標準 _search
API 來搜尋索引,以執行文字、k-NN 或混合式查詢。對於使用s3vector
引擎設定knn_vector
之欄位的查詢,OpenSearch 會自動將查詢卸載至對應的 S3 向量索引。
注意
使用s3vector
引擎時,重新整理語意僅適用於未使用s3vector
引擎的欄位。不過,您卸載至 的向量資料s3vector
會在文件成功編製索引後立即顯示。
搜尋查詢範例
GET my-first-s3vector-index/_search { "size": 2, "query": { "knn": { "my_vector_1": { "vector": [2.5, 3.5], "k": 2 } } } }
支援的映射參數
使用 s3vector
引擎時, knn_vector
欄位支援映射中的下列參數。
參數 | 必要 | 描述 | 支援的值 |
---|---|---|---|
type |
是 | 文件中存在的欄位類型。 | knn_vector |
dimension |
是 | 將導入索引的每個向量維度。 | >0、<=4096 |
space_type |
否 | 用於計算向量之間距離的向量空間。 | l2 , cosinesimil |
method.engine |
是 | 用於編製索引和搜尋的大約 k-NN 引擎。 | s3vector |
method.name |
否 | 最近的鄰近方法 | "" |
重要
使用s3vector
引擎不支援巢狀knn_vector
欄位類型
計量和計費
在宣布計量之前,此功能不會計費。
停用 s3vector 引擎
停用s3vector
引擎之前,請刪除目前正在使用的所有索引。否則,任何停用引擎的嘗試都會失敗。
另請注意,啟用或停用s3vector
引擎會在您的網域上觸發藍/綠部署。
若要停用s3vector
引擎,請編輯您的網域組態並設定 S3VectorsEngine.Enabled: false
。