2013-08-04 57 views
0

我需要在MongoDB集合上进行一些地理空间查询。我在GeoJSON点对象上创建了一个2dsphere索引。对象是这样的:地理空间查询不能在另一台PC上工作

{ "loc" : { "type" : "Point", "coordinates" : [ -122.419416, 37.77493 ] } } 

我添加使用

db.Venue.ensureIndex({loc:"2dsphere"}) 

它完美workes以及我的Mac上的索引。但后来我转移到Ubuntu PC并重新创建了数据库和索引。 但在Ubuntu上,地理空间查询不起作用。 MongoDB中说

{ errmsg: 'no geo index :(', ok: 0 } 

在我的Mac,db.Venue.getIndexes返回:

[ 
    { 
     "v" : 1, 
     "key" : { 
      "_id" : 1 
     }, 
     "ns" : "syftdb.Venue", 
     "name" : "_id_" 
    }, 
    { 
     "v" : 1, 
     "key" : { 
      "loc" : "2dsphere" 
     }, 
     "ns" : "syftdb.Venue", 
     "name" : "loc_2dsphere" 
    } 
] 

但在Ubuntu PC db.Venue.getIndexes()返回一个不同的对象:

[ 
{ 
    "v" : 1, 
    "key" : { 
     "_id" : 1 
    }, 
    "ns" : "syftdb.Venue", 
    "name" : "_id_" 
}, 
{ 
    "v" : 1, 
    "key" : { 
     "loc" : "2dsphere" 
    }, 
    "ns" : "syftdb.Venue", 
    "name" : "loc_" 
} 
] 

您看到名称字段不同。这是问题吗?名称字段必须相同吗?

蒙戈版本: 苹果:2.0.6 64位 Ubuntu的:2.4.4 64位

回答

1

2dsphere指标不可用MongoDB中版本早于2.4

是我的错!我问一个真正愚蠢的问题,而不先查询!

相关问题