文档

热搜Demo

更新时间:

Package 依赖查找:https://www.npmjs.com/

代码依赖

  • dependencies

@alicloud/credentials 
@alicloud/opensearch-util 
@alicloud/tea-typescript 
@alicloud/tea-util
  • devDependencies

typescript
ts-node

热搜搜索示例

import * as $Util from '@alicloud/tea-util';
import Client from "./Client";
import Config from "./Config";

// 创建 Config 配置实例
let config  = new Config();

// 配置 endpoint 统一的请求入口, 此信息可从业务控制台获取.
config.endpoint = "opensearch-cn-hangzhou.aliyuncs.com";

// 支持 protocol 配置网络请求协议, 默认为 'HTTP'. 支持配置 'HTTPS'/'HTTP'.
config.protocol = "HTTP";

// 支持 type 配置 sts/access_key 鉴权. 其中 type 默认为 'access_key' 鉴权. 使用 'sts' 可配置 RAM-STS 鉴权.
// 备选参数为:  sts 或者 access_key
config.type = "access_key";

// 如果使用 RAM-STS 鉴权, 请配置 security_token, 可使用阿里云 AssumeRole 获取 相关 STS 鉴权结构.
config.securityToken = "";

// 配置运行时参数, 时间参数数值单位为 ms.
let runtime = new $Util.RuntimeOptions({
  connectTimeout: 5000,
  readTimeout: 10000,
  autoretry: false,
  ignoreSSL: false,
  maxIdleConns: 50,
});

// 创建 opensearch Client 实例
let client = new Client(config);

// 指定 推送目标 app 名称或者版本信息.
const appName = "<appName>";


// ---------------  热词底纹搜索 ---------------
let hot_algoQuery = {
    "sort_type": "default",
    "hit": 10,
    "user_id": "a7a0d37c824b659f36a5b9e3b819fcdd"
  };
try {
  let pathname = `/v3/openapi/apps/${appName}/actions/hot`;
  let  result=  client._request("GET", pathname, hot_algoQuery, null, null, runtime);
  result.then(function (result)  {
    console.log(result);
  });
}
catch (e) {
  console.log(e);
}
说明

参考:热搜底纹

  • 本页导读 (0)
文档反馈