I'm using Apache Solr to index and search against my mongo database. When I index an entity in Solr, I save only the ID of that entity so that I can retrieve the full result from mongo. The problem is that because I'm only saving the ID, I don't know which collection that ID is in. So, here's what I'm thinking about, and input on any of these options would be great (or other options I haven't thought of)
Is it possible to search across all collections to find the appropriate entity by its ID?
- If this is possible, is it prone to being slow/inefficient?
Since the above approach doesn't seem very good to me, is it possible to create a compound index that could be used to find the appropriate entity in the appropriate collection?
Along with the ID, save the name of the collection in Solr, and return that along with the search results
- While this seems best from an efficiency standpoint, it seems like I might be creating problems for myself down the road if/when I need to change the names of collections, or add new ones
Edit: I'm using mongo's native ObjectId for the ID, so the ids should be unique across all collections