文档

restful api文档搜索Demo

更新时间:

通过SDK 调用向量检索版实例进行数据检索

通用代码示例

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:
        # 构造rest查询条件,具体查询语法请参考:https://help.aliyun.com/document_detail/2247643.html?spm=a2c4g.2247642.0.0
        data = {"query": "index_id: 1", "config": {"format": "json"}}
        json_str = json.dumps(data)

    	# 构造SearchRequestModel查询对象
        searchRequestModel = models.SearchRequestModel(body=json_str)

        # 替换{indexName}为待查询实例的索引表名
        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()

  • 本页导读 (0)