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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:46:44+00:00 2026-05-27T04:46:44+00:00

Been reading about map/reduce here and on other sites and I’m still not sure

  • 0

Been reading about map/reduce here and on other sites and I’m still not sure if it’s the right or wrong way to solve this problem.

I have three models:

User --  embeds many SearchRequests
SearchRequest -- references 1 Item
Item

What I need to do is get a bit of information from each model and then eliminate any results that don’t meet criteria. Is this a map/reduce?

The map I want:

user.email, user.name, item.name, item.amount, 
 item.url, searchRequest.amountCutoff

Then I think I’d reduce and elminate any records where:

item.amount > searchRequest.amountCutoff

The thing I’m having trouble with is how to get the item.name, item.amount in the map. This is what I have so far (map would be called on the Users collection):

map = "function() {  if (this.search_requests)
  for (var ar in this.search_requests) {

// this part needs help  ---vvvv
    var theItem= items.where(_id: this.search_requests[ar].item_id) 

    emit ( { },
     { this.email, 
       this.name, 
       this.search_requests[ar].item_id,
       this.search_requests[ar].amountCutoff, 
       theItem.name,
       theItem.amount
      }
    }
} "

^^ The syntax on that may be incorrect. I’m still learning. It almost looks like I need the mongo equivalent of LINQs range variable in there… not sure if that’s possible.

So my question: is it possible (or smart) to access another collection that isn’t the “mapping” collection in a map function?

  • 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-27T04:46:44+00:00Added an answer on May 27, 2026 at 4:46 am

    AFAIK, unfortunately, map/reduce doesn’t support for more than one collection for the moment.

    Since you know the criteria item.count > n, create a index on it and query out the documents. which should contains user’s reference, say userid.

    which could be done by running a javascript in mongoshell or you can write code in your environment.

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

Sidebar

Related Questions

I have been reading about collision detection in games on stackoverflow and other sites.
I've been reading about map/reduce so that I can improve my understanding of big
I've been reading about Python's multiprocessing module . I still don't think I have
I've been reading and testing a lot about it and could not get the
I've been reading about aggregation and composition here recently and how composition is basically
I have been reading about how read.table is not efficient for large data files.
Ive been reading about mysqli multi_query and couldnt find a way to do this
Have been reading about async and tasks and been attempting to convert the CopyFileEx
I've been reading about locales in PHP and it seems setlocale() has problems with
I've been reading about problems people are having with browsers caching an old version

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.