A pythonic tool for batch loading data files (json, parquet, csv, tsv) into ElasticSearch
Project description
Main features:
Batch upload CSV (actually any *SV) files to Elasticsearch
Batch upload JSON files / JSON lines to Elasticsearch
Batch upload parquet files to Elasticsearch
Pre defining custom mappings
Delete index before upload
Index documents with _id from the document itself
And more
Installation
Usage
(venv)/tmp $ elasticsearch_loader --help Usage: elasticsearch_loader [OPTIONS] COMMAND [ARGS]... Options: --bulk-size INTEGER How many docs to collect before writing to ElasticSearch --concurrency INTEGER How much worker threads to start --es-host TEXT Elasticsearch cluster entry point. eg. http://localhost:9200 --consistency TEXT Consistency level passed to bulk api --index TEXT Destination index name [required] --delete Delete index before import? --type TEXT Docs type [required] --id-field TEXT Specify field name that be used as document id --index-settings-file FILENAME Specify path to json file containing index mapping and settings --help Show this message and exit. Commands: csv json FILES with the format of [{"a": "1"}, {"b":... parquet
Examples
Load 2 CSV files
elasticsearch_loader --index incidents --type incident csv file1.csv file2.csv
Load 2 JSON lines files
elasticsearch_loader --index incidents --type incident json --json-lines file1.json.lines file2.json.lines
Load 2 parquet files
elasticsearch_loader --index incidents --type incident parquet file1.parquet file2.parquet
Read _id from incident_id field elasticsearch_loader --id-field incident_id --index incidents --type incident csv file1.csv file2.csv
Change bulk size
elasticsearch_loader --bulk-size 300 --index incidents --type incident csv file1.csv file2.csv
Change index concurrency
elasticsearch_loader --concurrency 20 --index incidents --type incident csv file1.csv file2.csv
Load custom mappings
elasticsearch_loader --index-settings-file samples/mappings.json --index incidents --type incident csv file1.csv file2.csv
Tests and sample data
Tests are located under test and can run by runnig tox input format can be found under samples
TODO
[x] parquet support
[x] progress bar
[ ] DLQ style out file for docs that didn’t got in
[ ] Python3 support
[ ] Flake8 test
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
Hashes for elasticsearch-loader-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0e11f97256073bad4b45b6b7c6f076f5a8d03c1d3e0f015a2bafedc82a1a8e1 |
|
MD5 | f68373f7f939d17ef2a231ae84646cd5 |
|
BLAKE2b-256 | 059a83a828c46ff8b13247725236810a210e09a37f20f03e9cf494acf4ecde3a |