Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8458315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:02:35+00:00 2026-06-10T13:02:35+00:00

I am using mongodb as my backend. I have to store similar document ids

  • 0

I am using mongodb as my backend. I have to store similar document ids in a list for each document. Here is a sample record in my collection.

{
   "_id": ObjectID("...."),
   "doc_name": "my_doc1",
   "doc_id": "doc_id_1",
   "similar_docs": ["doc_id_6", "doc_id_86", "doc_id_93"],
   "more_fields": "..."
}

This way I am keeping track of similar documents to each document.
Now I wish to have the complete json for all the similar documents to a given document. Right now I am implementing it using a for loop over the list of doc_id’s making a request to database for each doc_id. Is there any subtle way to do this work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:02:37+00:00Added an answer on June 10, 2026 at 1:02 pm

    You can have a single query, something along these lines:

    db.collection.find({_id: {$in: [doc_id1, doc_id2, ..]}});
    

    But if you wanted a way to somehow “expand” those ids into documents when querying for parent document, then you can’t do that. Unless you store full documents in that array (which can be expensive or impossible (if resulting document exceeds max document size)).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using MongoDB to hold a collection of documents. Each document has an _id
Using mongodb with the NoRM driver I have this document: { _id : ObjectId(0758030341b870c019591900),
I have a Document using mongoengine + mongodb as backend. and i want to
Using mongodb I'm trying to remove a property (_id) from a child collection (ListingFeatures)
I am using mongodb to store user's events, there's a document for every user,
I am using mongodb now. I have a blogpost collection, and it has a
I'm using MongoDB and need to remove duplicate records. I have a listing collection
I am considering using MongoDB to store documents that include a list of key/value
I'm using MongoDB as a backend for my project, but I don't specifically want
I'm building a simple web application in tornado.web using mongodb as the backend. 90%

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.