Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-4247

Not allowed to insert non-geo data into a geo-indexed field

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • v1.3.13
    • manual
    • 4
    • true

    Description

      Currently we do not allow users to insert non-geo data (for example, a string) into a field that has a geo index on it. Here is an example:

      > db.test.ensureIndex({a: '2dsphere'})
      {
              "createdCollectionAutomatically" : false,
              "numIndexesBefore" : 1,
              "numIndexesAfter" : 2,
              "ok" : 1
      }
      > db.test.remove({})
      WriteResult({ "nRemoved" : 0 })
      > db.test.insert({_id: 0, a: "this is not a test"})
      WriteResult({
              "nInserted" : 0,
              "writeError" : {
                      "code" : 16755,
                      "errmsg" : "insertDocument :: caused by :: 16755 Can't extract geo keys: { _id: 0.0, a: \"this is not a test\" }  geo element must be an array or object: a: \"this is not a test\""
              }
      })

      I could not find this limitation documented anywhere. We should make this clear to the users as it is a fairly major limitations of geo indexes.

      Attachments

        Activity

          People

            sam.kleinman Sam Kleinman (Inactive)
            andrew.emil@10gen.com Andrew Emil (Inactive)
            Jonathan Dahl Jonathan Dahl
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              7 years, 47 weeks, 4 days ago