I am having this issue with a field of type int-array. Using the aws-sdk for Node.js, I am submitting a document via the CloudSearchDomain.uploadDocuments() method. The JSON for the document (in the searchContent variable) is created in the node process, then I use:
var params = {
contentType: 'application/json',
documents: JSON.stringify([searchContent])
};
csd.uploadDocuments(params, function(err, data){
...(callback process)...
});
The non-stringified searchContent object looks like this:
{ id: 1,
type: 'Product',
hash_type_id: 'Product-1',
name: 'Test product',
description: 'A test product',
category: [ 2 ],
content: '<some text here>',
state: [ 1 ],
hash_all: '<some text>'
}
and stringified like this:
[{"id":1,"type":"Product","hash_type_id":"Product-1","name":"Test product","description":"A test product","content":" <some text>","category":[2],"state":[1],"hash_all":"<some text>"}]
The error I am getting is:
{
"message": "{ [\"The value of category cannot be a JSON array or object\"] }",
"code": "DocumentServiceException",
"time": "2014-11-20T01:24:27.499Z",
"statusCode": 400,
"retryable": false
}
As mentioned, the category field is int-array type. Why would I be getting this message?
UPDATE: I have also tried using a typed array (Int16Array) for the category field, with exactly the same result.
The document needs to be wrapped in the batch processing parameters. In a batch, each document needs to have this format:
And this needs to be in an array, even if it's just a single document. So the JSON for the document in the question becomes: