【发布时间】:2021-08-27 18:04:22
【问题描述】:
使用 Elasticsearch 包,我能够获得此输出。
res = es.search(index="*:*-logs-ndb-*", body=body, size=1)
output=res['hits']['hits']
output
[{'_type': '_doc',
'_source': {'Id': '10032',
'log_format': 'plain',
'consumer_time': '2021-06-09T08:55:58.115',
'type': 'application',
'message': 'Created {\n "Id": "10032",\n "category": {\n "type": "Scheduled"\n },\n "api": false,\n "settings": {},\n "LogicInfo": {\n "isReq": false\n }\n}',
'index_pattern': 'main'}}]
我正在尝试解析“消息”部分,以便在“创建”之后提出一个来自 {..} 的平面表(例如“Id”、“category”...作为列。)
有人能解释一下吗?我尝试了 res['hits']['hits']['message'] 或 res['hits']['hits'][0] 只是开始,但到目前为止没有运气。
对不起,如果这是一个非常新手的问题,但经过 3 天的努力,我已经放弃了.. -(
【问题讨论】:
标签: python json parsing elasticsearch