Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-80402

Support creating a geospatial index on an array field of GeoJSON Points

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution

      If you have a document containing an array field of geopoints, such as:

      {
          _id: ObjectId("64e3e7f2ab7c883c6dc7e844"),
          locations: [
            { type: 'Point', coordinates: [ 1.23, 4.56 ] },
            { type: 'Point', coordinates: [ 1.23, 4.32 ] }
          ],
          name: 'hello'
      }

      Then trying to create an index on the array field fails with an error like:

      > db.points.createIndex({ locations: "2dsphere" })MongoServerError: Index build failed: ab490695-9294-4389-a26e-649092d06c13: Collection geo.points ( 45b925d5-29ae-4d01-9073-039c9ae572ae ) :: caused by :: Can't extract geo keys: { _id: ObjectId('64e3e7f2ab7c883c6dc7e844'), locations: [ { type: "Point", coordinates: [ 1.23, 4.56 ] }, { type: "Point", coordinates: [ 1.23, 4.32 ] } ], name: "hello" }  Point must only contain numeric elements 

      If there isn't a technical limitation in supporting this and it wouldn't be a huge lift, i think it would be nice to support this – otherwise, the documentation should probably state somewhere that this is explicitly unsupported

       

       

            Assignee:
            kateryna.kamenieva@mongodb.com Katya Kamenieva
            Reporter:
            jonathan.lee@mongodb.com Jonathan Lee
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: