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

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!

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.

1 Like

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