node.jsmongodbelasticsearchmongodb-queryelasticsearch-indices

How to query on multiple collections with Elasticsearch


Database: MongoDB, Server: Nodejs

I have around 10 collections on my MongoDB database, Can I able to query on those collections at the same time with Elasticsearch and return appropriate results?

examples queries send from users


Solution

  • If you are using Elasticsearch version lower than 6.X, then you can have multiple types(collection in your case) in a single Elasticsearch index.

    for example, if twitter is your index, you can have tweets, users, employees, user-profiles so on, in single elasticsearch index and searching on twitter index will internally search in all these types.

    But if you are using Elasticsearch index greater than 6.X and use the different index for storing these collections, then can you use the multiple indices in your query as explained in the Elasticsearch docs.