restful api文檔搜索Demo
更新時(shí)間:
通過SDK 調(diào)用向量檢索版實(shí)例進(jìn)行數(shù)據(jù)檢索
通用代碼示例
from alibabacloud_ha3engine import models, client
from Tea.exceptions import TeaException, RetryError
import json
Config = models.Config(
endpoint="ha-cn-***********.public.ha.aliyuncs.com",
instance_id="ha-cn-***********",
protocol="http",
access_user_name="username",
access_pass_word="passsword"
)
# 初始化 Ha3Engine Client
ha3EngineClient = client.Client(Config)
def search():
try:
# 構(gòu)造rest查詢條件,具體查詢語法請參考:http://bestwisewords.com/document_detail/2247643.html?spm=a2c4g.2247642.0.0
data = {"query": "index_id: 1", "config": {"format": "json"}}
json_str = json.dumps(data)
# 構(gòu)造SearchRequestModel查詢對象
searchRequestModel = models.SearchRequestModel(body=json_str)
# 替換{indexName}為待查詢實(shí)例的索引表名
responseModel = ha3EngineClient.search_rest(request=searchRequestModel, index_name="{indexName}")
print(responseModel.body)
except TeaException as e:
print(f"send request with TeaException : {e}")
except RetryError as e:
print(f"send request with Connection Exception : {e}")
search()
文檔內(nèi)容是否對您有幫助?