Query on multiple collections at once with mongodb

Can I able to search on multiple mongodb collections with elastic search at once?


Elasticsearch does not search in databases but in its own indices.
You can create one index per database, send the data from each database to the right index and search across multiple indices at once.

1 Like

thanks for the reply, First of all, I'm new to elastic search and zero-knowledge, I had a problem with my application database and when I have come across the internet I found elastic search able to solve my problem but I don't have any idea how it can, that's why I asked the question here. Ok, I will explain the problem.

My application(buy and sell) have around five to ten categories

eg: vehicles, real estate, and cloths

I thought of creating separate MongoDB collections for each category because each of the categories contains with different fields

eg: vehicle[km, body type, brand], cloths[size, color, gender],

This would be very easy to manage and scale. The problem here is searching if a user searches

eg: parts

the search should query all collections and return appropriate results and another circumstance if the user sorts the ads from newest to the oldest application should sort the latest post ads from all categories(databases) to oldest ads in order.

Please clarify can able to do this with the elastic search after I will make my hands dirty with Elastic search


Not sure I understood everything but IMHO yes. As soon as you have JSON documents indexed in elasticsearch you can query easily, compute aggregations, in near real time...

1 Like

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