# Is there any way to get client.search and client.querySuggestion' data at once?

**URL:** https://discuss.elastic.co/t/is-there-any-way-to-get-client-search-and-client-querysuggestion-data-at-once/219695
**Category:** Elastic Search
**Tags:** elastic-app-search
**Created:** [February 18, 2020, 2:35am UTC](https://discuss.elastic.co/t/is-there-any-way-to-get-client-search-and-client-querysuggestion-data-at-once/219695 "2020-02-18T02:35:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Hayden-NTW](https://avatars.discourse-cdn.com/v4/letter/h/c89c15/32.png) [@Hayden-NTW](https://discuss.elastic.co/u/Hayden-NTW)
#### Post date: [February 18, 2020, 2:35am UTC](https://discuss.elastic.co/t/is-there-any-way-to-get-client-search-and-client-querysuggestion-data-at-once/219695/1 "2020-02-18T02:35:58Z")

</div>

I'm so new for elastic/app-searce.

I'm using @elastic/app-search-javascript@7.6.0.  
I need client.search results and client.querySuggestion's result at once, so I wrote code like this.

```
    client.querySuggestion(keyword, option)
                           .then(resultList => {
                                target.innerHTML = ''
                                let results = resultList.results.documents
                                target.append(...)

                                client.search(keyword, options)
                                    .then(resultList => {
                                        resultList.results.forEach(result => {
                                            target.append(...)
                                        })
                                    })
                            })

```

As you just read, I queried twice(querySuggestion and search) and I think it'll be slow.  
Is there any function or way to get both results at once?

Thanks for reading, thanks for helping me!

---

<div class="post-metadata">

### Author: ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)
#### Post date: [February 18, 2020, 12:06pm UTC](https://discuss.elastic.co/t/is-there-any-way-to-get-client-search-and-client-querysuggestion-data-at-once/219695/2 "2020-02-18T12:06:03Z")

</div>

There's no way to combine them into a single query, but your code is executing the two queries sequentially, if you execute them in parallel and merge the result you will get better performance.

---

<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: [March 17, 2020, 6:48pm UTC](https://discuss.elastic.co/t/is-there-any-way-to-get-client-search-and-client-querysuggestion-data-at-once/219695/4 "2020-03-17T18:48:40Z")

</div>

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