从Excel文档导入数据后,在数据上创建地理空间索引时出错

时间:2016-05-24 10:22:05

标签: excel mongodb indexing geospatial 2dsphere

我已从Excel文档导入此数据。

 {
    "_id" : ObjectId("57440d63a458f726a8f95bfe"),
    "state" : "WEST BENGAL",
    "bank" : "STATE BANK OF INDIA",
    "ifsc" : "SBIN0000001",
    "micr code" : "700002021",
    "branch" : "KOLKATA MAIN",
    "address" : "SAMRIDDHI BHAWAN, 1 STRAND ROAD, KOLKATA 700 001",
    "latlong" : "22.569435,88.342932",
    "latitude" : "22.569435",
    "longitude" : "88.342932",
    "city" : "KOLKATA",
    "district" : "KOLKATA",
    "loc" : [
            "88.34",
            "22.57"
        ]
}

这是我的示例文档。我无法在loc上创建地理空间索引。如何创作?

1 个答案:

答案 0 :(得分:0)

数组的值必须采用特殊格式才能创建2D索引。

Geospatial Indexes

  

数组的值可以是数组,如[55.5,42.3]或   嵌入式文档,如{lng:55.5,lat:42.3}。

我可以在下面的文档上创建2d索引。我想你需要重新访问excel导入过程。

{
    "_id" : ObjectId("57440d63a458f726a8f95bfe"),
    "state" : "WEST BENGAL",
    "bank" : "STATE BANK OF INDIA",
    "ifsc" : "SBIN0000001",
    "micr code" : "700002021",
    "branch" : "KOLKATA MAIN",
    "address" : "SAMRIDDHI BHAWAN, 1 STRAND ROAD, KOLKATA 700 001",
    "latlong" : "22.569435,88.342932",
    "latitude" : "22.569435",
    "longitude" : "88.342932",
    "city" : "KOLKATA",
    "district" : "KOLKATA",
    "loc" : [
            88.34,
            22.57
        ]
}