title: Mongoose 5.3.8 - Can't Extract Geo Keys with MultiLineString and $push
body: <p>I am attempting to $push a coordinate pair into a document that contains a GeoJSON MultiLineString that is nested like this: [[[Number]]]</p>
  
  <p>When I findOneAndUpdate like so:</p>
  
  <p><strong>req.body.point</strong> = [-123.347, 48.43649]</p>
  
  <pre><code>Route.findOneAndUpdate({name: req.body.name},
  {'$push': { "route.coordinates.0": req.body.point}}, {new: true})
  .then(doc =&gt; {
      return res.send(doc)
  }).catch(err =&gt; {
      res.send(err)
  })
  </code></pre>
  
  <p>I receive the error message:</p>
  
  <pre><code>errmsg": "Can't extract geo keys: { _id: ObjectId('5be9eef393311d2d2c6130fd').......
  Point must only contain numeric elements",
  "code": 16755,
  </code></pre>
  
  <hr>
  
  <p>My coordinates are valid [long, lat] format as mongo expects. 
  is there something I'm missing here?</p>
  
  <hr>
  
  <p>This is my MultiLineString Schema:</p>
  
  <pre><code>const MultiLineStringSchema = new Schema({
    type: {
      type: String,
      enum: ['MultiLineString'],
      required: true,
      default: 'MultiLineString'
    },
    coordinates: {
      type: [[[Number]]],
      required: true
    }
  });
  </code></pre>
  
  <p>This is my route schema:</p>
  
  <pre><code>var { MultiLineStringSchema } = require('./GeoJson-Schemas')
  
  const RouteSchema = new mongoose.Schema({
    name: String,
    route: {
      type: MultiLineStringSchema,
      required: true
    }
  });
  RouteSchema.index({ route: "2dsphere" });
  </code></pre>
  
  <p><strong>EDIT 2:</strong>
  Here is the Route document stored that persisted the error. I have re-created the error with this document and have updated the matching _id in the error message above.</p>
  
  <pre><code>{
      "_id": {
          "$oid": "5be9eef393311d2d2c6130fd"
      },
      "name": "A Route",
      "route": {
          "type": "MultiLineString",
          "coordinates": [
              [
                  [
                      -123.3867645,
                      48.4813423
                  ],
                  [
                      -123.3785248,
                      48.4592626
                  ],
                  [
                      -123.3766365,
                      48.4527165
                  ],
                  [
                      -123.3756924,
                      48.4523749
                  ],
                  [
                      -123.3722591,
                      48.4549366
                  ],
                  [
                      -123.3704567,
                      48.4559612
                  ]
              ]
          ],
          "_id": {
              "$oid": "5be9eef393311d2d2c6130fe"
          }
      },
      "__v": 0
  }
  </code></pre>
  
  <p>Moving ahead one step I have added the {_id: false} option to the MultiLineString subdocument and reinitialized a fresh collection. Upon storing the new document like so: </p>
  
  <pre><code>{
      "_id": "5be9f076e1caaa23682d80de",
      "name": "A Route",
      "route": {
          "type": "MultiLineString",
          "coordinates": [
              [
                  [
                      -123.3867645,
                      48.4813423
                  ],
                  [
                      -123.3785248,
                      48.4592626
                  ],
                  [
                      -123.3766365,
                      48.4527165
                  ],
                  [
                      -123.3756924,
                      48.4523749
                  ],
                  [
                      -123.3722591,
                      48.4549366
                  ],
                  [
                      -123.3704567,
                      48.4559612
                  ]
              ]
          ]
      },
      "__v": 0
  }
  </code></pre>
  
  <p>I attempt to findOneAndUpdate with the exact syntax:</p>
  
  <pre><code>Route.findOneAndUpdate({name},
      {'$push': { "route.coordinates.0": point}}, {new: true})
      .then(doc =&gt; {
          return res.send(doc)
      }).catch(err =&gt; {
          res.send(err)
      })
  </code></pre>
  
  <p>And recive the same error:</p>
  
  <pre><code>"errmsg": "Can't extract geo keys: { _id: ObjectId('5be9f076e1caaa23682d80de')...
  Point must only contain numeric elements",
  "code": 16755,
  </code></pre>
  
  <p><strong>EDIT 3:</strong></p>
  
  <p>Moving ahead once more I have updated the RouteSchema <strong>removing</strong> the <strong>subdocument</strong> entirely to be like so:</p>
  
  <pre><code>const RouteSchema = new mongoose.Schema({
    name: String,
    route: {
      type: {
        type: String,
        enum: ['MultiLineString'],
        required: true,
        default: 'MultiLineString'
      },
      coordinates: {
        type: [[[Number]]],
        required: true
      }
    }
  });
  </code></pre>
  
  <p>I store the document like so:</p>
  
  <pre><code>{
      "_id": {
          "$oid": "5be9f3915fc64e3548603766"
      },
      "route": {
          "type": "MultiLineString",
          "coordinates": [
              [
                  [
                      -123.3867645,
                      48.4813423
                  ],
                  [
                      -123.3785248,
                      48.4592626
                  ],
                  [
                      -123.3766365,
                      48.4527165
                  ],
                  [
                      -123.3756924,
                      48.4523749
                  ],
                  [
                      -123.3722591,
                      48.4549366
                  ],
                  [
                      -123.3704567,
                      48.4559612
                  ]
              ]
          ]
      },
      "name": "A Route",
      "__v": 0
  }
  </code></pre>
  
  <p>and FindOneAndUpdate again with the exact syntax, and receive the same error.</p>
  
  <pre><code>Route.findOneAndUpdate({name},
      {'$push': { "route.coordinates.0": point}}, {new: true})
      .then(doc =&gt; {
          return res.send(doc)
      }).catch(err =&gt; {
          res.send(err)
      })
  
  
  "errmsg": "Can't extract geo keys: { _id: ObjectId('5be9f3915fc64e3548603766')
  Point must only contain numeric elements",
  "code": 16755,
  </code></pre>
  
  <p><strong>EDIT 4:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/N7jdb.png" rel="nofollow noreferrer">mLab hosted instance mongo version 3.6.6 indexes on <strong>Route</strong> collection PHOTO</a></p>
  
  <p>Running db.routes.getIndexes() ON shell connection provides the following.</p>
  
  <pre><code> [
              {
                      "v" : 2,
                      "key" : {
                              "_id" : 1
                      },
                      "name" : "_id_",
                      "ns" : "testbench.routes"
              },
              {
                      "v" : 2,
                      "key" : {
                              "route" : "2dsphere"
                      },
                      "name" : "route_2dsphere",
                      "ns" : "testbench.routes",
                      "background" : true,
                      "2dsphereIndexVersion" : 3
              }
      ]
  </code></pre>