我想为我的Elasticsearch文档结构生成一些文档。问题是我在我的索引中存储了嵌套的JSON,但我想记录Elasticsearch正在生成的flattend JSON格式¹。
有没有办法将此JSON压扁,类似于Elasticsearch使用ES Java API生成的方式?
如果可能,我不想为此任务启动Elasticsearch。
示例JSON:
{
"title": "Nest eggs",
"body": "Making your money work...",
"tags": [ "cash", "shares" ],
"comments": [
{
"name": "John Smith",
"comment": "Great article",
"age": 28,
"stars": 4,
"date": "2014-09-01"
},
{
"name": "Alice White",
"comment": "More like this please",
"age": 31,
"stars": 5,
"date": "2014-10-22"
}
]
}
一旦Elasticsearch将其展平,该文档将如下所示。
{
"title": [ eggs, nest ],
"body": [ making, money, work, your ],
"tags": [ cash, shares ],
"comments.name": [ alice, john, smith, white ],
"comments.comment": [ article, great, like, more, please, this ],
"comments.age": [ 28, 31 ],
"comments.stars": [ 4, 5 ],
"comments.date": [ 2014-09-01, 2014-10-22 ]
}
[1] https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-objects.html