Through the dev tools in Elastic with this command :
GET "my_index"/_search/?filter_path=hits.hits._source&size=1
I have :
{
"hits" : {
"hits" : [
{
"_source" : {
"@timestamp" : "2020-10-10T14:00:00.000Z",
"Date" : "2020-10-10T14:00:00Z",
"MeanValue" : 58.23516987
}
}
]
}
}
It is an exemple of 1 hit
I wanted to know if it is possible with maybe a Painless Code or any other solution in Elastic to change the name of the source key and get :
{
"timestamp": "2020-10-10T14:00:00Z"
"value" : 58.23516987
}
I did it with Python by getting the data with REST API but I wonder if there is a solution to have that output directly from Elastic search
No, it's not possible to change the structure of the response you get from Elasticsearch.
As you've discovered, you can use
filter_path
to only return a selected set of fields, but the structure itself cannot be changed.