日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

插入Doc

本文介紹如何通過HTTP API向Collection中插入Doc。

說明
  1. 插入Doc時若指定id已存在,已存在的Doc不會被覆蓋,本次插入Doc操作無效。

  2. 插入Doc時若不指定id,則在插入過程中會自動生成id,并在返回結(jié)果中攜帶id信息。

前提條件

Method與URL

POST https://{Endpoint}/v1/collections/{CollectionName}/docs

使用示例

說明
  1. 需要使用您的api-key替換示例中的YOUR_API_KEY、您的Cluster Endpoint替換示例中的YOUR_CLUSTER_ENDPOINT,代碼才能正常運(yùn)行。

  2. 本示例需要參考新建Collection-使用示例提前創(chuàng)建好名稱為quickstart的Collection

插入Doc

curl -XPOST \
  -H 'dashvector-auth-token: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "docs": [{"id": "1", "vector": [0.1, 0.2, 0.3, 0.4]}]
  }' https://YOUR_CLUSTER_ENDPOINT/v1/collections/quickstart/docs

# example output:
# {"code": 0, "message": "Success", "requests_id": "6fda9f39-ee83-45cb-bfc5-ff353d650568", "output": [{"doc_op": "insert", "id": "1", "code": 0, "message": ""}]}

插入不帶有Id的Doc

curl -XPOST \
  -H 'dashvector-auth-token: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "docs": [{"vector": [0.1, 0.2, 0.3, 0.4]}]
  }' https://YOUR_CLUSTER_ENDPOINT/v1/collections/quickstart/docs

# example output:
# {"request_id":"1602e7fb-227d-4a39-bfc5-0066763f20ab","code":0,"message":"Success","output":[{"doc_op":"insert","id":"2196112409600","code":0,"message":""}]}

插入帶有Fields的Doc

curl -XPOST \
  -H 'dashvector-auth-token: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "docs": [
      {
      	"id": "2", 
        "vector": [0.2, 0.3, 0.4, 0.5], 
        "fields": 
          {
            "age": 70, 
            "name": "zhangshan",
            "anykey1": "str-value",
            "anykey2": 1,
            "anykey3": true,
            "anykey4": 3.1415926
          }
      }
    ]
   }' https://YOUR_CLUSTER_ENDPOINT/v1/collections/quickstart/docs

# example output:
# {"request_id":"6de0609c-476f-4c2c-a732-4f8745f24536","code":0,"message":"Success","output":[{"doc_op":"insert","id":"2","code":0,"message":""}]}

批量插入Doc

curl -XPOST \
  -H 'dashvector-auth-token: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{ 
    "docs": [ 
      {"id": "3", "vector": [0.3, 0.4, 0.5, 0.6]},
      {"id": "4", "vector": [0.4, 0.5, 0.6, 0.7], "fields": {"age": 20, "name": "zhangsan"}},
      {"id": "5", "vector": [0.5, 0.6, 0.7, 0.8], "fields": {"anykey": "anyvalue"}}
    ]
   }' https://YOUR_CLUSTER_ENDPOINT/v1/collections/quickstart/docs

# example output:
# {"request_id":"b0bf32b0-92dc-4fa5-bf33-e6b27f567c60","code":0,"message":"Success","output":[{"doc_op":"insert","id":"3","code":0,"message":""},{"doc_op":"insert","id":"4","code":0,"message":""},{"doc_op":"insert","id":"5","code":0,"message":""}]}

插入帶有Sparse Vector的Doc

curl -XPOST \
  -H 'dashvector-auth-token: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "docs": [
      {"id": "6", "vector": [0.1, 0.2, 0.3, 0.4], "sparse_vector":{"1":0.4, "10000":0.6, "222222":0.8}}
    ]
   }' https://YOUR_CLUSTER_ENDPOINT/v1/collections/quickstart/docs

# example output:
# {"request_id":"9ffed1ac-bdbe-4341-a1f7-0e25afce4b47","code":0,"message":"Success","output":[{"doc_op":"insert","id":"6","code":0,"message":""}]}

插入多向量集合

curl -XPOST \
  -H 'dashvector-auth-token: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{ 
    "docs": [ 
      {"id": "1", "vectors": {"title": [0.3, 0.4, 0.5, 0.6], "content": [0.3, 0.4, 0.5, 0.6, 0.7, 0.8]}},
      {"id": "2", "vectors": {"title": [0.1, 0.2, 0.3, 0.4]},"fields": {"author": "zhangsan"}},
      {"id": "3", "vectors": {"content": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6]}, "fields": {"anykey": "anyvalue"}}
    ]
}' https://YOUR_CLUSTER_ENDPOINT/v1/collections/multi_vector_demo/docs

# example output:
# {"request_id":"f98999e1-ab30-4bea-940c-a25b4b5bbb84","code":0,"message":"Success","output":[{"doc_op":"insert","id":"1","code":0,"message":""},{"doc_op":"insert","id":"2","code":0,"message":""},{"doc_op":"insert","id":"3","code":0,"message":""}]}

入?yún)⒚枋?/b>

參數(shù)

Location

類型

必填

說明

{Endpoint}

path

str

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

{CollectionName}

path

str

Collection名稱

dashvector-auth-token

header

str

api-key

docs

body

array

待插入的Doc列表

partition

body

str

Partition名稱

出參描述

字段

類型

描述

示例

code

int

返回值,參考返回狀態(tài)碼說明

0

message

str

返回消息

success

request_id

str

請求唯一id

19215409-ea66-4db9-8764-26ce2eb5bb99

output

array

返回插入Doc的結(jié)果,DocOpResult列表

usage

map

對Serverless實例(按量付費(fèi))集合的Doc插入請求,成功后返回實際消耗的寫請求單元數(shù)

{
    Usage: {
        write_units: 3
    }
}