Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Lambda code to add a document to CloudSearch using javascript SDK
addToIndex = function (bucketName, docName, docContent, context) {
var csd = new AWS.CloudSearchDomain({
endpoint: CS_NAME+'.'+SERVICES_REGION+'',
apiVersion: '2013-01-01'
// see documentation at :
var jbatch = [ {"type": "add",
"id": bucketName+':'+docName,
"fields": {"content": docContent,
"content_encoding": "ISO-8859-1",
"content_type": "text/plain",
"resourcename": docName }, } ];
var params = { contentType: 'application/json', documents: JSON.stringify(jbatch) };
csd.uploadDocuments(params, function(err, data) {
if (err) {
console.log('CloudSearchDomain ERROR');
else {
console.log('CloudSearchDomain SUCCESS');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment