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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:51:24+00:00 2026-06-16T16:51:24+00:00

I have a set of objects in a mongodb database that have measurements embedded.

  • 0

I have a set of objects in a mongodb database that have measurements embedded. I’m trying to do a map/reduce to get stats about the measurements. Well I ran into some problems with that so I just made it as simple as possible: get the number of measurements for each one.

m = function() {
    emit (mp, { meas:  this.measurements }); 
 };

r = function() {
    return { count: meas.length };
 };

 res = db.meas_points.mapReduce(m, r,
    {query : { measurements : {$exists: true}}},
    {out: { "measurements_stats" }} );

When I run this query I get an error:

Mon Jan 2 16:05:53 SyntaxError: missing : after property id (shell):1

I’m trying to see what this means in the context of my map/reduce but I’m just not seeing it. I lifted the code from the mongodb website ( http://www.mongodb.org/display/DOCS/MapReduce Shell Example 2) and adapted it to my needs. Seems like I’m doing everything right but I keep getting this cryptic error. I’m not using the id field at all — is it possible that I have a malformed record or something?

  • 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-16T16:51:25+00:00Added an answer on June 16, 2026 at 4:51 pm

    In this line

    return { count: meas.length };
    

    It is not able to resolve meas You need to modify the signature of the reduce function.

    var r = function(mp, measValues) {
                          return Array.sum(measValues.length);
                      };
    

    Here measValues passed to this reduce function itself is an array

    Note: If mp in the map function is the id/key of your collection meas_points then change that line to this.mp

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

Sidebar

Related Questions

I have an open source project that deals with mongodb database. I am trying
I have a set of entity objects in my iOS Core Data database that
I have a set of objects in Mongodb that each have a set of
I have a set of objects that I want to conform to an interface,
I have an odd problem with Django. I have a set of objects that
Say I have a set myset of custom objects that may be equal although
I have a class that serializes a set of objects (using XML serialization) that
I have an API that filters a set of objects based on the ID
I have a set of objects that the user can sort arbitrarily. I would
I have a specs2 test which uses a FakeApplication and an embedded mongodb database.

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.