Hello there. New to Elastic Search. Kindly suggest a solution to add a new field conditionally to my document
current data in ElasticSearch
"_index": "test",
"_type": "logs",
"_id": "AWDgIKFCvg3odC71dRbc",
"_score": 0.09685399,
"_source": {
"HighTH": 120000,
"@timestamp": "2018-01-10T12:52:02.684Z",
"Cust": 16926,
"areaCode": 123
"application": "myapps",
"@version": "1",
"host": "localhost",
"Run_date": "2018-01-03T16:00:00.000Z",
"LowTH": 10000,
"message": "04-JAN-2018,MN,16926,206472,15785,120000,10000",
"Trans": 206472,
"Cntry_code": "NO",
"Trans_GPS": 15785
}
i need to add a field "gpsStrength": 209845 into data only if "Cust" = 16926 and "areaCode" = 123.
the required result need to be
"_index": "test",
"_type": "logs",
"_id": "AWDgIKFCvg3odC71dRbc",
"_score": 0.09685399,
"_source": {
"HighTH": 120000,
"@timestamp": "2018-01-10T12:52:02.684Z",
"Cust": 16926,
"areaCode": 123
"application": "myapps",
"@version": "1",
"host": "localhost",
"Run_date": "2018-01-03T16:00:00.000Z",
"LowTH": 10000,
"message": "04-JAN-2018,MN,16926,206472,15785,120000,10000",
"Trans": 206472,
"Cntry_code": "NO",
"Trans_GPS": 15785,
"gpsStrength": 209845
}
I tried using index type and id which is updating tha data
POST test/logs/AWDgIKFCvg3odC71dRbc/_update?pretty { "doc": { "gpsStrength" : "209845" }
but required query based on _source values
kindly note that i used dynamic mapping