Here I only have to allow few data coming from JSON and index in Elasticsearch. So what is the perfect way to do it, rather than delete each separately?
var elasticData= JSON.parse(result.body);
elasticData = elasticData.res;
elasticData["id"] = elasticData._id;
delete elasticData["__v"];
delete elasticData["_id"];
delete elasticData["addressee"];
delete elasticData["abbreviation"];
delete elasticData["care_of"];
delete elasticData["address_1"];
delete elasticData["address_2"];
delete elasticData["company_id_legacy"];
elasticSearch_common.createCompanyIndex(elasticData);
For Example: I only have to pass ("name","id","address") and rest of them I don't want to pass it. But there's lots of other data(s) are available in same JSON.
{
"userId":"34234234234gjgjg894734g",
"company":{
"id" : "21",
"addressee" : {
"addressee" : "EXAMPLE",
"title_name" : "",
"salutation" : "Dear:",
"comments" : "",
"email" : "[email protected]",
"phone" : "",
"fax" : "",
"extention_group" : "",
"ext" : ""
},
"abbreviation" : "",
"care_of" : "",
"address_1" : "2",
"address_2" : "",
"address_3" : "",
"state" : "CA",
"zip" : "90024",
"is_deleted" : false,
"company_code" : "sdas",
"parent_company" : null,
"name" : "NIOE",
"createdBy" : "Dat",
"modifiedBy" : "Dat",
"createdDate" : "2019-08-22T19:10:50.000+0000",
"modifiedDate" : "2019-08-22T19:10:50.000+0000",
}
This is the actual JSON, And I want below as the elasticsearch index data to be pushed.
{ name: 'NIOE',
id: '21' }