Im working on news site project.
I want to search news as a whole and i need to return a message if that news exists already otherwise need to insert.
As the news can have multiple paragraphs ,could anyone please suggest ideal way to design the scheme also how to achieve this requirement .
Your question is vague. The question I’m wondering here is: what makes a news unique? What kind of query would you be running to know if the news already exists or not in your database?
If you have a unique ID for example, then I would use this for the
_id field and simply do an upsert to update the fields in the existing document or insert the document if it doesn’t exists.
If you are storing an entire newspaper article in MongoDB and you are wondering if a “similar” document already exists with an article that is paraphrasing the existing document… I guess you could build an algorithm based on some Atlas Search (FTS) scoring. But that’s completely up to you to decide what’s “the same” and what’s not.