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 6957431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:00:04+00:00 2026-05-27T15:00:04+00:00

This question is largely a sanity check. I’ve organized a DB by a collection

  • 0

This question is largely a sanity check. I’ve organized a DB by a collection of stories and a collection of users. Each story has an array of ‘voters’ who have voted on that object. Each user also has an array of ‘friends’. What I want to do is search for only stories that my friends have voted on, but additionally to be able to sort these by the number of friends voting on that item.

My initial thinking is this: To index the field of voters in the Story objects. Then do a map reduce query for just stories on this indexed voter field using the array of ‘friends’ from the user document, with a grouping function to count the number of times each story shows up? Not sure if that is correct.. I’m also not sure if this would scale.. Thoughts and suggestions appreciated.

  • 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-05-27T15:00:05+00:00Added an answer on May 27, 2026 at 3:00 pm

    I think you should use a background worker that runs your M/R query periodically and stores the results in a collection which you can the query very easily, e.g

    TopStories { 
      "UserId" : ObjectId("..."),
      "List" : [ 
                  { "TotalVotes" : 200, 
                    "FriendVotes" : 28, 
                    "StoryName" : "test", 
                    "StoryId" : ObjectId('...') 
                   }, 
                   {
                     /* etc. */ }
                   } 
               ]
    }
    

    This is trivial to query, but not very flexible. A more flexible structure, avoiding an embedded list:

    TopStory { 
       "UserId": ObjectId("..."),
       "StoryId" : ObjectId("..."),
       "StoryName" : "foo",
       "FriendVotes" : 28,
       "TotalVotes" : 200
       // etc.
    }
    

    The latter can be used to sort by the number of total votes as well, for example.

    M/R used to be ‘the big hammer’, which should not be run in real-time from a web frontend or anything. There were plans to improve this, but I don’t know the current state of that, so I’d play it safe. I also believe that this M/R job won’t be very fast if your collections grow big, expect this to run in the order of dozens of seconds if not minutes, rather than milliseconds.

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

Sidebar

Related Questions

I'm coming largely from a c++ background, but I think this question applies to
This question and answer shows how to send a file as a byte array
(This question is over 6 years old and probably no longer has any relevance.)
This question is about removing sequences from an array, not duplicates in the strict
I know this sort of question has been asked before , but I still
Related to this question , I decided to check the UDFs in my data
Largely as a follow-up to this question test driven asynch tasks I have come
This is largely a syntactical question. How does one set the UIButton action selector
I know this question has been asked multiple number of times and i have
This question is kind of an add-on to this question In C#, a switch

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.