# How to execute multiple search query in node.js using elastic search and promises?

**URL:** <https://discuss.elastic.co/t/how-to-execute-multiple-search-query-in-node-js-using-elastic-search-and-promises/126411>\
**Category:** Elasticsearch\
**Created:** [April 2, 2018, 9:53am UTC](https://discuss.elastic.co/t/how-to-execute-multiple-search-query-in-node-js-using-elastic-search-and-promises/126411 "2018-04-02T09:53:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jasso](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@Jasso](https://discuss.elastic.co/u/Jasso)\
**Post date:** [April 2, 2018, 9:53am UTC](https://discuss.elastic.co/t/how-to-execute-multiple-search-query-in-node-js-using-elastic-search-and-promises/126411/1 "2018-04-02T09:53:30Z")

</div>

Working Query:

```auto
POST /_msearch
    { "index": "INDEX_NAME_1", "type": "callStart" }
    { "query": { "match_all": {}}}
    { "index": "INDEX_NAME_2", "type": "callEnd" }
    { "query": { "match_all": {}}}

```

If I run the above query in kibana console i'm getting the response for both "callstart" and "callEnd".

Please find the below code that i have done in node js for single type "callEnd" and i'm getting the response back for the type of "callEnd". When i tried for multiple type(callStart & callEnd) i'm not able to fetch the data. can anyone please help me for fetching data with multiple types.

Node Js code :

```auto
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 {
                     let elasticResponse=response.hits.hits;
                     resolve(response);
             }
         })
     });

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 30, 2018, 9:53am UTC](https://discuss.elastic.co/t/how-to-execute-multiple-search-query-in-node-js-using-elastic-search-and-promises/126411/2 "2018-04-30T09:53:32Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
