How do I update (not overwrite) a record in Elasticsearch using Node.js?

136
May 05, 2019, at 07:40 AM

Writing a Lambda, I am grabbing a file from S3 and sending it to Elasticsearch. When I attached the file using pipeline-attachment, it attaches correctly but overwrites all my fields. How do I just attach the file to my record while maintaining my previous fields in my response? Can't find the documentation for this action.

I am using the Elasticsearch.index to initially attach the file, which works but overwrites all my other fields. I have tried the Elasticsearch.update, but cant get it to work.

s3.getObject({Bucket: bucket, Key: key}, function (err, data) {
               if (err) {
                        console.log(err, err.stack); // an error occurred
                        context.fail();
               } else {
                  console.log('data: ', data); // successful response
                  var attachment = data.Body.toString('base64'); 
                  console.log('attachment: ', attachment);
                  elasticsearch.index(
                 {
                       index: 'files',
                       pipeline: 'attachment',
                       type: 'file',
                       id: key,
                       body: {
                              data: attachment
                             }
                 },
                   function (error, resp) {
                       if (error) {
                          console.trace('index error!', error);
                       } else {
                          console.log('index response', resp);
                          context.succeed();
                       }
                   }
                   );
                }
           });
Rent Charter Buses Company
READ ALSO
How to actually download a file from s3 using AWS Amplify in ReactJS

How to actually download a file from s3 using AWS Amplify in ReactJS

How do I download a file using AWS-Amplify in ReactJS? Storageget() returns the full url to the file, and Storage

127
Route to a html file after png image displayed

Route to a html file after png image displayed

In my javascript file i want as user clicks on correct answer as C after which an image "5png" is displayed ,now after image is displayed then route should happen to followup

131
Node oracledb execute pl/sql function

Node oracledb execute pl/sql function

I created something like below:

149
can't Preview the application in aws cloud9 when uses express application generator

can't Preview the application in aws cloud9 when uses express application generator

I am using AWS cloud 9when I use express application generator, I can't preview my application

139