用一行命令将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什么会导致程序在它似乎拥有的监视器上被阻止?   java Android studio设置视图的背景色   java我可以保存一个文本文件而不给用户修改它的能力吗?   pdfbox PDFBOX2。0:java堆堆栈错误   java是维护和操作AllowList的有效方法   JAVAsql。SQLException:找不到适合jdbc的驱动程序:mysql://localhost:3306/asd性爱   如何使用java。lang.NullPointerException:void 安卓。支持v7。应用程序。ActionBar。setElevation(float)“”在空对象引用上'   java调试空指针异常   java正则表达式,以按令牌的特定匹配项拆分,同时忽略其他匹配项   java为JPanel设置边框上的笔划   并发@Schedule方法的java行为   如何在Java中使用泛型与语言运算符和泛型类扩展数   java Rhino Javascript如何为异常堆栈跟踪标记字符串源   运行可执行jar时发生java错误,无法找到或加载主类