0

我有一个地理编码集合,当我尝试查询已地理编码的文档数量时会引发错误。这是我的查询;

Account.exists("locations.coordinates" => false).count

这是它抛出的错误;

failed with error 13068: "exception: geo field only has 1 element :: caused by :: $exists: false"

根据错误消息,这意味着我的一些坐标数组只有一个元素。有人可以帮助我了解如何在locations.coordinates 中查找只有一个元素的帐户的语法吗?

注意:如果我删除 2d 索引,我可以查询没有错误,我可以重建索引,没问题。我正在寻找识别问题文件的方法。

4

1 回答 1

0

在早期版本的 MongoDB 中,这样做:

Account.exists("locations.coordinates" => false).count

(或类似的)工作。但是,在更高版本(2.4+)中,您似乎想要搜索“null”。

Account.exists("locations.coordinates" => null).count
于 2013-05-30T20:29:46.947 回答