1.2.0 • Published 5 years ago

ali-opensearch-v3 v1.2.0

Weekly downloads
5
License
GPL-3.0
Repository
github
Last release
5 years ago

ali-opensearch-v3

Description

根据阿里云 Opensearch V3 的 API 开发的 nodejs SDK

Usage

npm i ali-opensearch-v3

const { Client, QueryBuilder, Publisher } = require('ali-opensearch-v3');
// 新建一个Client:
const api = new Client('your host', 'appName', {
  accessKeyId,
  accessKeySecret
});

// 构建 query
const qb = QueryBuilder.create();

const queryString = qb
  .setQuery('your query string')
  .setFormat('json/fulljson/xml')
  .addFetchField('field you want to fetch')
  .setHit('hit number')
  // compile your query to percent encode string:

// 搜索
api.search('resource path', qb, isStandard?); // promise

// 构建push的content:
const pub = Publisher.create('ADD/UPDATE/DELETE');
pub.addField('field key', 'field value');
// 将 pub 放入一个 array 中,然后用 Publisher的static方法生成bulk action:
const bulk = [];
bulk.push(pub);

// Publish:
api.publish('resource path', bulk); // promise

Testing

Please add a test.config.json file under /test directory directly for testing api in the follwing format:

{
  "host": "<your host>",
  "accessKeyId": "<your accessKeyId>",
  "accessKeySecret": "<your accessKeySecret>",
  "appName": "<the appName you want to search for in your apps>",
  "query": "<The resource string of the searcch>",
  "publish": {
    "resource": "<resource path>", // /question/actions/bulk,
    "tableName": "<tableName>", // question
    "operations": [
      {
        "cmd": : "<ADD, UPDATE, DELETE>",
        "fields": [
          {
            "key": "<Your schema key>",
            "value": "<The value you want to post>"
          },
          ...
        ]
      }
    ]
  }
}

If it is not added, the test suit will skip it.

License

GPL v3 License

1.2.0

5 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago