I'm trying to modify my elastic query by adding and removing items from an array. In the array below, I want to remove the element that contains 'item2'. How can I achieve this by checking if the key 'item2' exists and then deleting that specific item?
let array = [
{
terms: {
item1: [
'1111111111111',
'2222222222222',
'3333333333333',
'4444444444444'
]
}
},
{
terms: {
item2: [
'aaaaaaaaaaaaaaaaaaaaaaa',
'bbbbbbbbbbbbbbbbbbbbbbb',
'ccccccccccccccccccccccc'
]
}
},
{
range: {
item3: {
from: 0,
to: 99999
}
}
}
];