[SERVER-6169] "invalid property id" when using $or in mapreduce Created: 22/Jun/12  Updated: 11/Jul/16  Resolved: 22/Jun/12

Status: Closed
Project: Core Server
Component/s: MapReduce, Querying
Affects Version/s: 2.0.5
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Kerim Satirli Assignee: Aaron Staple
Resolution: Done Votes: 0
Labels: mapreduce
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

EC2; Amazon AMI; mongo is running in a sharded replicaset


Operating System: Linux
Participants:

 Description   

Using the m/r function with an $or query appears to be impossible right now. We are using the query below for one of our map reduces and are getting this error:

SyntaxError: invalid property id

mongo mentions line 78; below are lines 73-84:

db.runCommand({
 mapreduce : "clients_raw",
 map : m,
 reduce : r,
 query : {
  { "_id.DAY": "2012-06-22" , $or : [ {"_id.CLIENT_ID": 123},  {"_id.CLIENT_ID": 456} ] }
 },
 out : {
  merge : "clients"
 },
 finalize : f
});

Running the query through a find generates the results we expect; removing the $or condition, too, generates results we expect. It seems as if combining $or with another field however, is not possible at this point.



 Comments   
Comment by Kerim Satirli [ 22/Jun/12 ]

Thanks for the pointer! This works.

Comment by Aaron Staple [ 22/Jun/12 ]

It looks like your query line is:

query : {
  { "_id.DAY": "2012-06-22" , $or : [ {"_id.CLIENT_ID": 123},  {"_id.CLIENT_ID": 456} ] }
 },

This is not valid javascript because there is no field name in the object named "query" for the value { "_id.DAY": "2012-06-22" , $or : [

{"_id.CLIENT_ID": 123}

,

{"_id.CLIENT_ID": 456}

] }.

Generated at Thu Feb 08 03:10:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.