[SERVER-23080] $near errors on MultiPoint $geometry query Created: 11/Mar/16  Updated: 14/Mar/16  Resolved: 11/Mar/16

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 3.0.10
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: David Jhanyan Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

I have following indexes:

> db.world_map.getIndexes()
[
        {
                "v" : 1,
                "key" : {
                        "_id" : 1
                },
                "name" : "_id_",
                "ns" : "ws.world_map"
        },
        {
                "v" : 1,
                "key" : {
                        "coord" : "2dsphere"
                },
                "name" : "coord_2dsphere",
                "ns" : "ws.world_map",
                "2dsphereIndexVersion" : 2
        }
]

Get error on queries:

> db.world_map.find({'coord': {'$near': {'$minDistance': 4000, '$geometry': {'type': 'MultiPoint', 'coordinates': [[35.0, 25.0675], [35.03375, 25.045]]}, '$maxDistance': 10000}}})
Error: error: {
        "$err" : "Can't canonicalize query: BadValue invalid point in geo near query $geometry argument: { type: \"MultiPoint\", coordinates: [ [ 35.0, 25.0675 ], [ 35.03375, 25.045 ] ] }  Point must only contain numeric elements",
        "code" : 17287
}
 
> db.world_map.find({'coord': {'$near': {'$geometry': {'type': 'MultiPoint', 'coordinates': [[35.0, 25.0675], [35.03375, 25.045]]}}}})
Error: error: {
        "$err" : "Can't canonicalize query: BadValue invalid point in geo near query $geometry argument: { type: \"MultiPoint\", coordinates: [ [ 35.0, 25.0675 ], [ 35.03375, 25.045 ] ] }  Point must only contain numeric elements",
        "code" : 17287
}
 
> db.world_map.find({'coord': {'$near': {'$geometry': {'type': 'MultiPoint', 'coordinates': [[35.0, 25.0675]]}}}})
Error: error: {
        "$err" : "Can't canonicalize query: BadValue invalid point in geo near query $geometry argument: { type: \"MultiPoint\", coordinates: [ [ 35.0, 25.0675 ] ] }  Point must only contain numeric elements",
        "code" : 17287
}

Also I found report about the same issue: https://groups.google.com/forum/#!msg/mongodb-user/58FURF8-_Vs/b3ufnu146tkJ



 Comments   
Comment by David Jhanyan [ 11/Mar/16 ]

Thanks. It's really my mistake.

Comment by Ramon Fernandez Marina [ 11/Mar/16 ]

davo, this is expected behavior as per the $near documentation:

The $near operator can specify either a GeoJSON point or legacy coordinate point.

To the best of my knowledge one can't specify a multipoint for these queries.

Regards,
Ramón.

Comment by David Jhanyan [ 11/Mar/16 ]

On 3.2.4 it also fails

Generated at Thu Feb 08 04:02:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.