我通过运行范围查询在ElasticSearch中生成了json,它以以下格式生成:
{
"took" : 63,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1000,
"max_score" : null,
"hits" : [ {
"_index" : "bank",
"_type" : "_doc",
"_id" : "0",
"sort": [0],
"_score" : null,
"_source" : {"account_number":0,"balance":16623,"firstname":"Bradshaw","lastname":"Mckenzie","age":29,"gender":"F","address":"244 Columbus Place","employer":"Euron","email":"bradshawmckenzie@euron.com","city":"Hobucken","state":"CO"}
}, {
"_index" : "bank",
"_type" : "_doc",
"_id" : "1",
"sort": [1],
"_score" : null,
"_source" : {"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"amberduke@pyrami.com","city":"Brogan","state":"IL"}
}, ...
]
}
}
我需要将此json导入回ElasticSearch。我已经从Elastic看过_bulk api,但是它需要不同的json格式。有人可以帮我吗?
如何使用Shell将此文件更改为正确的json文件,以便可以将此json文件转储到ElasticSearch?
答案 0 :(得分:0)
尚不清楚您要尝试做什么。.但是根据您的描述,您应该查看_reindex
API。它将使您可以将查询结果发送到新的不同索引中。
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html
它们显示了一个提供查询的示例:
POST _reindex
{
"source": {
"index": "twitter",
"type": "_doc",
"query": {
"term": {
"user": "kimchy"
}
}
},
"dest": {
"index": "new_twitter"
}
}