I have written below query to fetch latest two document to get few fields like #processor, allocated_memory for a particular server.
I want to extend the query to compare these fields i.e. #processor, allocated_memory for the 2 filtered documents and return the difference value.
"query": {
"term": {
"servername.keyword": {
"value": "prod01"
}
}
},
"size": 2,
"sort": [
{
"logtime": {
"order": "desc"
}
}
],
"_source":{
"includes":["logtime","#processors","allocated_memory_mb"]
}