ElasticSearch dump full index to a csv file

冷暖自知 提交于 2019-12-05 11:58:19

Disclaimer: I'm the author of estab.


estab exports elasticsearch fields as tab separated values. If you do not have too many fields, it's easy to explicitly export them all. Internally estab uses the scan and scroll API.

Example:

Assume your index contains documents like:

{
    "name": "Kiwi",
    "genus": "Apteryx",
    "populations": [
        {"location": "North Island", "size": 2500},
        {"location": "Little Barrier Island", "size": 2000}
    ]
}

Then you can export a whole index via:

$ estab -f 'name genus populations.location populations.size'
Kiwi    Apteryx North Island|Little Barrier Island  2500|2000

Note that nested fields are not easily mapped into a tabular form. estab by default separates multiple values by | and you can refer to nested fields via usual dot notation.

You could use the Scan and Scroll API. Then you wouldn't have a monstrous JSON file to parse--you could do it in much smaller batches.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!