用于cloudsearch的latlon格式

时间:2015-05-18 13:53:46

标签: amazon amazon-dynamodb amazon-cloudsearch

我想在云搜索中进行地理搜索,我会像这样进行索引

enter image description here

上传文件时

[{"type": "add", "id": "kdhrlfh1304532987654321987654321", "fields":{"name": "user1", "latlon":[12.628611, 120.694152] , "phoneverifiedon": "2015-05-04T15:39:03Z", "fbnumfriends": 172}},
{"type": "add", "id": "kdhrlfh1304532987654321987654322", "fields": {"name": "user2", "latlon":[12.628645,20.694178] , "phoneverifiedon": "2015-05-04T15:39:03Z", "fbnumfriends": 172}}]

我得到以下错误

Status: error
Adds: 0
Deletes: 0
Errors:
{ ["Field "latlon" must have array type to have multiple values (near operation with index 1; document_id kdhrlfh1304532987654321987654321)","Validation error for field 'latlon': Invalid latlon value 12.628611"] }

我为" latlon "尝试了多种格式领域 请建议在cloudsearch中使用lat long的正确格式是什么

1 个答案:

答案 0 :(得分:3)

doc提交的正确语法是单个字符串,其中两个值以逗号分隔,例如"latlon" : "12.628611, 120.694152"

[
  {
    "type": "add",
    "id": "kdhrlfh1304532987654321987654321",
    "fields": {
      "name": "user1",
      "latlon" : "12.628611, 120.694152"
      "phoneverifiedon": "2015-05-04T15:39:03Z",
      "fbnumfriends": 172
    }
  }
]

提交语法与查询语法不匹配肯定令人困惑,查询语法使用数组来表示lat-lon。

https://forums.aws.amazon.com/thread.jspa?threadID=151633