2dsphere index requires field. "Can't parse geometry from element: location: null"

XMLWordPrintableJSON

    • Fully Compatible
    • ALL
    • Hide

      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
      }

      Show
      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 }
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

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

              Assignee:
              Unassigned
              Reporter:
              Maksims Mihejevs
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: