本文由簡體中文內容自動轉碼而成。阿里雲不保證此自動轉碼的準確性、完整性及時效性。本文内容請以簡體中文版本為準。

建立Collection

更新時間:2024-07-13 00:20

本文介紹如何通過HTTP API建立一個新的Collection。

前提條件

Method與URL

HTTP
POST https://{Endpoint}/v1/collections

使用樣本

說明

需要使用您的api-key替換樣本中的YOUR_API_KEY、您的Cluster Endpoint替換樣本中的YOUR_CLUSTER_ENDPOINT,代碼才能正常運行。

Shell
# 建立一個名稱為quickstart、向量維度為4、
# 向量資料類型為float(預設值)、
# 距離度量方式為dotproduct(內積)的Collection
# 並預先定義三個Field,名稱為name、weight、age,資料類型分別為string、float、int

curl -XPOST \
  -H 'dashvector-auth-token: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "quickstart", 
    "dimension": 4, 
    "metric": "dotproduct", 
    "fields_schema": {
      "name": "STRING",
      "age": "INT",
      "weight": "FLOAT"
    }
  }' https://YOUR_CLUSTER_ENDPOINT/v1/collections

# example output:
# {"request_id":"19215409-ea66-4db9-8764-26ce2eb5bb99","code":0,"message":""}

入參描述

參數

Location

類型

必填

說明

{Endpoint}

path

str

Cluster的Endpoint,可在控制台Cluster詳情中查看

dashvector-auth-token

header

str

api-key

name

body

str

待建立的Collection名稱

dimension

body

int

向量維度,取值範圍 (1, 20000]

dtype

body

str

向量資料類型,"FLOAT"(預設)/"INT"

fields_schema

body

object

Fields定義

metric

body

str

距離度量方式,"euclidean"/"dotproduct"/"cosine"(預設)

值為cosine時,dtype必須為FLOAT

extra_params

body

object

選擇性參數:

  • quantize_type:量化策略,詳情參考向量動態量化

  • auto_id: 自動產生主鍵,預設開啟

說明

出參描述

欄位

類型

描述

樣本

code

int

傳回值,參考返回狀態代碼說明

0

message

str

返回訊息

success

request_id

str

請求唯一id

19215409-ea66-4db9-8764-26ce2eb5bb99

  • 本頁導讀 (1, M)
  • 前提條件
  • Method與URL
  • 使用樣本
  • 入參描述
  • 出參描述
文檔反饋