Hi,
I have a requirement of maintaining similarity. For e.g. I have a collections of articles on various topics. For each document in my collection, I have an array of similar/related articles. Now I need to write a query that will - given an article ID, fetch all the documents from the same collection where the article ID is within the array of similar articles for the query parameter. Currently I can think of only 2 solutions:
- Find the document for given article ID and then use the similar article array in another find query to find IDs in fetched array of IDs
- Keep a separate collection of related articles and use $lookup to make a join
Is there a more efficient way to a. get everything in single find/aggregation AND b. avoid creating separate collection?