Elasticsearch : 6.3
I'm trying to update the nested field by filtering the particular Book. Below is the sample record.
{
"StoreName":"test",
"StoreID":"12435",
"BookInfo":[
{
"Name":"Book1",
"Comments":[
{
"date":"2019-01-07",
"Comment":"this is a nice book"
},
{
"date":"2019-01-06",
"Comment":"this is a nice book"
},
{
"date":"2019-01-04",
"Comment":"this is a nice book"
},
{
"date":"2019-01-03",
"Comment":"this is a nice book"
}
],
"UPC":2435466,
},
{
"Name":"Book2",
"Comments":[
{
"date":"2019-01-07",
"Comment":"this is a nice book"
},
{
"date":"2019-01-06",
"Comment":"this is a nice book"
},
{
"date":"2019-01-04",
"Comment":"this is a nice book"
},
{
"date":"2019-01-03",
"Comment":"this is a nice book"
}
],
"UPC":576868345657,
},
}
]
}
Here, we have multiple stores and each store has multiple books. For each book, we store the user comments on daily basis. I want to add the date and comment under [BookInfo.Comments] by checking whether the comment on that particular date is already there or not. If it's already there, then I'll need to skip it if not then append the new comment. I tried doing it by update API but I couldn't filter the particular book and update the comments for it from the list of available books. Can someone help me with this? Thanks in advance.