[SERVER-3571] $near query with limit > 100 only provides 100 input documents to map/reduce. Created: 10/Aug/11  Updated: 06/Dec/22  Resolved: 15/Mar/17

Status: Closed
Project: Core Server
Component/s: MapReduce
Affects Version/s: 1.9.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Bernie Hackett Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 8
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File geo.tgz     File near_m_r_repro.js    
Issue Links:
Related
is related to SERVER-4341 disable non-default sort(), skip() an... Closed
is related to SERVER-14515 Remove default limit from geoNear ope... Closed
Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

Repro steps:

  • mongorestore the attached database
  • Run the attached JS script.

Output should look like this:

Count of $near query results:
100
Count of $near query results with limit(500):
500
Results from map/reduce with no limit:

{
	"result" : "output",
	"timeMillis" : 62,
	"counts" : {
		"input" : 100,
		"emit" : 100,
		"output" : 2
	},
	"ok" : 1
}

Results from map/reduce with limit(10):

{
	"result" : "output",
	"timeMillis" : 4,
	"counts" : {
		"input" : 10,
		"emit" : 10,
		"output" : 1
	},
	"ok" : 1
}

Results from map/reduce with limit(500):

{
	"result" : "output",
	"timeMillis" : 7,
	"counts" : {
		"input" : 100,
		"emit" : 100,
		"output" : 2
	},
	"ok" : 1
}



 Comments   
Comment by David Storch [ 15/Mar/17 ]

I'm resolving this ticket as Gone Away, since it is fixed in recent versions. Bernie's repro script produces the following output against a recent build of master:

Count of $near query results:
29470
Count of $near query results with limit(500):
500
Results from map/reduce with no limit:
{
	"result" : "output",
	"timeMillis" : 694,
	"counts" : {
		"input" : 29470,
		"emit" : 29470,
		"reduce" : 1772,
		"output" : 51
	},
	"ok" : 1,
	"operationTime" : Timestamp(0, 0)
}
Results from map/reduce with limit(10):
{
	"result" : "output",
	"timeMillis" : 562,
	"counts" : {
		"input" : 10,
		"emit" : 10,
		"reduce" : 1,
		"output" : 1
	},
	"ok" : 1,
	"operationTime" : Timestamp(0, 0)
}
Results from map/reduce with limit(500):
{
	"result" : "output",
	"timeMillis" : 713,
	"counts" : {
		"input" : 500,
		"emit" : 500,
		"reduce" : 11,
		"output" : 3
	},
	"ok" : 1,
	"operationTime" : Timestamp(0, 0)
}

The limit is now enforced correctly rather than defaulting to a limit of 100. I believe, but have not confirmed, that this was fixed under SERVER-14515.

Comment by Bernie Hackett [ 16/Aug/11 ]

This is related to this mongodb-user post:

https://groups.google.com/group/mongodb-user/browse_thread/thread/bcd99a391c78bac8?pli=1#

Comment by Bernie Hackett [ 16/Aug/11 ]

mongodump of the repro database with geospatial index

Comment by Bernie Hackett [ 16/Aug/11 ]

JS repro script.

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