user3619843
user3619843

Reputation: 51

latlon format for cloudsearch

I want to do Geographic search in cloud search, I do indexing like this:

enter image description here

when I uploading document

[{"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}}]

I got below error

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"] }

I tried multiple format for "latlon" field please suggest what is the correct format for the lat long in cloudsearch

Upvotes: 0

Views: 1076

Answers (1)

alexroussos
alexroussos

Reputation: 2681

The correct syntax for doc submission is a single string with the two values comma-separated, eg "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
    }
  }
]

It is definitely confusing that the submission syntax doesn't match the query syntax, which uses an array to represent lat-lon.

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

Upvotes: 4

Related Questions