[SERVER-9926] 2dsphere index requires field. "Can't parse geometry from element: location: null" Created: 13/Jun/13  Updated: 10/Dec/14  Resolved: 14/Jun/13

Status: Closed
Project: Core Server
Component/s: Geo, Index Maintenance, Internal Code
Affects Version/s: 2.4.4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Maksims Mihejevs Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: indexing
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac OS X 64 bit


Issue Links:
Duplicate
duplicates SERVER-9639 2dsphere indexes with {2dsphereIndexV... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

In terminal:
> mongo
> use test
> db.items.insert([ { location:

{ lng: 1, lat: 2 }

},

{ location: null }

])
> db.items.ensureIndex(

{ location: '2dsphere' }

)

{
"err" : "Can't parse geometry from element: location: null",
"code" : 16700,
"n" : 0,
"connectionId" : 132,
"ok" : 1
}

Participants:

 Description   

Trying to create 2dsphere index for collection on field that sometimes in null.
It allows to create 2d index, but not 2dsphere.



 Comments   
Comment by Daniel Pasette (Inactive) [ 14/Jun/13 ]

The difference between 2d and 2dsphere indexes is that the input data is validated in 2dsphere. The behavior you describe in 2d indexes is arguably a bug, but it would be backward breaking to change this behavior. Thus, you can happily insert

{location: 'foo'}

or

{location: 1}

into a 2d index as well.

I think this ticket is what you really are looking for, however it is not yet scheduled: SERVER-9639.

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