0

我有一个集合(“停止”),其中包含从 CSV 导入的 14000 条记录。每条记录中都包含一些地理空间数据,我已将其转换为数组,因此每个记录基本上如下所示:

{
  _id: ...,
  // other fields
  "loc": [
    153.019073,
    -27.467834
  ]
}

当我运行db.stops.ensureIndex({ loc: '2d' })它给出错误:

需要位置对象,位置数组的格式不正确

我想其中一个领域出了点问题,但我不知道是哪一个。有任何想法吗?

4

1 回答 1

1

问题是有一条记录没有正确导入(可能是文件末尾的空行)。

为了找到它(后来删除它),我使用了$where运算符:

db.stops.find({ $where: 'typeof this.loc[0] != "number"' })
于 2012-12-20T14:30:41.410 回答