Search data irrespective of any collection

Hi Techie,
We are advised to use Atlas Search to search in our application.
Our usecase is comething like below.
In our application there are >1000 collections are there. We have to provide details of document when user searches anything. The search should happen irrespective of any collection.

We had gone through some tutorials of dynamic and static mapping.
We Found dynamic mapping is easier but lots of overhead in terms of disk usage and performance. So thought of using static mapping. We are using springboot based java projects. Also please share the best practices used by industry.

Need few tutorials and examples.
Thanks in advance!

Hey! Here are some articles and tutorials that might be interesting to you:

1 Like

Thank you for the quick response.
We have a bit different use case, where as an end user he/she doesn’t know in which collection wants to search. Even same string might exists in multiple collections. We have the requirement to search the given string across all collections. How feasible is this searching a string across different collections ?

One possible way is like create Atlas Search index with same name for all collections and use wildcard (*) while searching. Is it wise to use and performant ?

It’s feasible to search across multiple collections. You can use $lookup to join collections in the same database, then run a query in the sub-pipeline using $search (but note that $lookup can be resource-intensive), or you can use $unionWith and $search together.

Here are some tutorials that might help you get started:

Run $lookup with Atlas Search $search

Use $unionWith with Atlas Search $search

Thank you for sharing the tutorials.
Our usecase is to search across all collections. We tried applying $unionWith on few collections and it returns expected results.
To make it work we have to write so much repeatative code for all collections (>500).
I read some tutorial where it says mongo atlas designed to search only on single collection.
For safer side we wanted to confirm you guys, if you have some better approach to achieve this in a very generic way.