Import JSON raw data to ElasticSearch using Python in one line of commands
Project description
Alexander Liu
To import raw JSON data files to ElasticSearch using Python in one line of commands
Installation
pip install jsonpyes
In the past we import data in this way. Too many jobs by hands…
Using ElasticSearch Bulk API to import this data, sometimes ES only recognizes data in its API way.
But now let json-py-es glue them all.
jsonpyes
Instructions:
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
1. Only validating
jsonpyes --data raw_data.json --check
If the json data file is valid:
If the json data file is invalid:
2. Only importing without validating
Notice: If the raw JSON data file is invalid, ElasticSearch will not import it.
jsonpyes --data raw_data.json --bulk http://localhost:9200 --import --index myindex2 --type mytype2
Or enable multi-threads jsonpyes --data raw_data.json --bulk http://localhost:9200 --import --index myindex2 --type mytype2 --thread 8
jsonpyes supports multi-threads when importing data to elasticsearch
As you can see these two containers have same docs loaded, if we use *–thread 8* it could be slightly faster. That really depends on your computer/server resources. This was tested on a 4GB RAM / 2.4Ghz intel i5 Linux x64 laptop system.
And it works.
3. Both validating and importing
jsonpyes --data raw_data.json --bulk http://localhost:9200 --import --index myindex1 --type mytype1 --check
And it works.
Happy hacking!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file jsonpyes-1.2.21.tar.gz
.
File metadata
- Download URL: jsonpyes-1.2.21.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94cc088ae776115efb2558ff9bfa5c1539849bc9ee7f28db37e0eff4b8c5c22a |
|
MD5 | c14cb130b12c71a2321d44b98d38a4ba |
|
BLAKE2b-256 | e21a0b40b0674ccf77509fae6b5fc47b3b479a8b9a283a162d0fa623dc94defe |