重新格式化来自弹性搜索的资源
Reformate sources from elastic search
使用以下命令通过 Elastic 中的开发工具:
GET "my_index"/_search/?filter_path=hits.hits._source&size=1
我有:
{
"hits" : {
"hits" : [
{
"_source" : {
"@timestamp" : "2020-10-10T14:00:00.000Z",
"Date" : "2020-10-10T14:00:00Z",
"MeanValue" : 58.23516987
}
}
]
}
}
是1命中的例子
我想知道是否可以使用 Painless Code 或 Elastic 中的任何其他解决方案来更改源密钥的名称并获得:
{
"timestamp": "2020-10-10T14:00:00Z"
"value" : 58.23516987
}
我用 Python 通过 REST API 获取数据来做到这一点,但我想知道是否有直接从 Elastic search
输出的解决方案
不,无法更改您从 Elasticsearch 获得的响应的结构。
正如您所发现的,您可以使用 filter_path
来仅 return 一组选定的字段,但结构本身无法更改。
使用以下命令通过 Elastic 中的开发工具:
GET "my_index"/_search/?filter_path=hits.hits._source&size=1
我有:
{
"hits" : {
"hits" : [
{
"_source" : {
"@timestamp" : "2020-10-10T14:00:00.000Z",
"Date" : "2020-10-10T14:00:00Z",
"MeanValue" : 58.23516987
}
}
]
}
}
是1命中的例子
我想知道是否可以使用 Painless Code 或 Elastic 中的任何其他解决方案来更改源密钥的名称并获得:
{
"timestamp": "2020-10-10T14:00:00Z"
"value" : 58.23516987
}
我用 Python 通过 REST API 获取数据来做到这一点,但我想知道是否有直接从 Elastic search
输出的解决方案不,无法更改您从 Elasticsearch 获得的响应的结构。
正如您所发现的,您可以使用 filter_path
来仅 return 一组选定的字段,但结构本身无法更改。