1

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

  • sort collections for the lastest created post on all collections
  • full-text search on all collections
0

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

can I able to create types for all my categories(eg: vehicles, cloths) inside a single index and use one query to search across all of the types?
yes, if you are using below ES 6.X :), although wouldn't recommend that as latest version is 7.6 and these types have been deprecated and will be removed in soon to release 8.X , so later on when you upgrade your ES you will face a lot of issues, instead you can use the multiple indices API to search on your multiple indices specific to each collection in your case :)
0

You can create separate indices for each collection and use aliases to query all of them.

Regarding querying lastest created post on all collections, depending on your use case, you can use single index per collection or create index by day/month to partition data.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.