小编pra*_*sso的帖子

如何使用弹性搜索和承诺在 node.js 中执行多个搜索查询?

弹性搜索代码:

POST /_msearch
{ "index": "INDEX_NAME_1", "type": "TYPE_NAME_1" }
{ "query": { "match_all": {}}}
{ "index": "INDEX_NAME_2", "type": "TYPE_NAME_2" }
{ "query": { "match_all": {}}}
Run Code Online (Sandbox Code Playgroud)

参考链接http://teknosrc.com/execute-multiple-search-query-elasticsearch/#comment-8578(参考示例 1)

节点js代码:

return new Promise(function (resolve, reject) {
        elasticClient.search({
             index: '*:logstash-prod-*',
             type: 'callEnd',
             size: 10000,
             body: {
                 query: {

                     range: {
                         "@timestamp": {
                             "gte": startTime,
                             "lte": endTime
                         }
                     }
                 }
             },
         }, function (error, response, status) {
             if (error) {
                    reject(error);
             }
             else {
                     console.log("show the response" + JSON.stringify(response));
                     let elasticResponse=response.hits.hits;
                     resolve(response); …
Run Code Online (Sandbox Code Playgroud)

node.js elasticsearch

3
推荐指数
1
解决办法
2627
查看次数

标签 统计

elasticsearch ×1

node.js ×1