用一行命令将json原始数据导入elasticsearch的工具

jsonpyes的Python项目详细描述


json副本

DownloadsBuild StatusGitHub releaseGitHub license

亚历山大刘

  • 用一行命令将原始json数据文件导入elasticsearch

jsonpyes diagram

非常快——处理大数据的速度是原来的4到10倍。

安装

pip install jsonpyes

Notice: Before using pip to install jsonpyes, firstly you need to install python-pip on your system. ( Supports Python Python2.7, 3.3, 3,4, 3.5, 3.6 )

Jsonpyes

user interface

说明:

There are 3 proccesses of importing raw JSON data to ElasticSearch
1. Only validating raw JSON data
2. Without validating ,just import data to ElasticSearch
3. After validating successfully, then import data to ElasticSearch

A valid JSON file here refers to a JSON file stacked with many lines of data

file valid_data.json and its content

{"key1": "valueA", "key2": {"sub_key1": "value2A", "sub_key2": ["Good", "Morning"]}}
{"key1": "valueB", "key2": {"sub_key1": "value2B", "sub_key2": ["Good", "Afternoon"]}}
...
{"key1": "valueC", "key2": {"sub_key1": "value2C", "sub_key2": ["Good", "Evening"]}}

包含的功能

1.验证json格式数据

jsonpyes --data raw_data.json --check

如果json数据文件有效:

json valid

如果json数据文件无效:

json invalid

2。仅导入而不验证

jsonpyes --data raw_data.json --bulk http://localhost:9200 --import --index myindex2 --type mytype2

注意:如果原始json数据文件无效,jsonpyes将不会导入它。

或者启用多线程jsonpyes --data raw_data.json --bulk http://localhost:9200 --import --index myindex2 --type mytype2 --thread 8

no threads

jsonpyes在将数据导入ElasticSearch时支持多线程

多线程比较
  1. 无多线程

    benchmarks

  2. 用8个线程和jsonpyes将文件切割成碎片,然后公平地分配给工作者

    use helpers.bulk API with multi-threads

As you can see these two containers have same docs loaded, if we use --thread 8 it could be several times faster, usually 5 to 10 times faster. That really depends on your computer/server resources. This was tested on a 4GB RAM / 2.4Ghz intel i5 Linux x64 laptop system.

而且有效。

it works

3。验证和导入

jsonpyes --data raw_data.json --bulk http://localhost:9200 --import --index myindex1 --type mytype1 --check

validating and importing

而且有效。

the results

参考

  • 算法手写

handwritting

快乐黑客!

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java Square类   java Android RecyclerView内部视图寻呼机   java类变量:公共访问只读,但私有访问r/w   java不兼容ClassChangeError java8   安卓java on on参数,如参数iNIT.C++C++   java如何在下面的代码中根据我的喜好设置JTextArea和JTextField的大小?   java使用CustomAdapter更改ListView的显示方式   jakarta ee什么是Java Servlet?   传递给Javasocket程序的参数   java为什么我的计划任务在这两者之间有很长的延迟   Java“迭代器”关键字   java获取数据库SQLite Android中插入行的行ID   网络如何在Java应用程序中设置H2嵌入式数据库,以便在小型网络中使用?   数组Java:写出所有包含K1的Nbit序列   java返回随机字符串键的整数值   在java中解析到日期的字符串时保留时区   java如何修复“运行配置错误:[在SDK中找不到Rails]”?   Java包装器OutofMemory