ElasticSearch: how to search from multiple indexes

I have a situation where I need to search from multiple indexes (products and users). Below is a sample query I am using to do that search


With the above API request, it only returns search results for the product index. But if I search using the below API it returns search results for users index


As you can see I am passing same value for "q" parameter. I need to search for both product and users index and check if there is the word "wood" in any attribute in both indexes. How can I achieve this

>Solution :

You can pass multiple index names instead of _all as it will search in other indices that you don’t intent to by using the comma seprated index name like


Although, _all should also fetch the result from users index which you get when you specify its name, you need to debug why its happening, maybe increase the size param to 1000 as by default Elasticsearch returns only 10 results and it seems in case of _all all the top results coming from products index only.

Leave a Reply