doersong / load_csv_or_json_to_elasticsearch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

load_csv_or_json_to_elasticsearch

Related info: https://towardsdatascience.com/from-scratch-to-search-setup-elasticsearch-under-4-minutes-load-a-csv-with-python-and-read-e31405d244f1

python3 load_csv_or_json_to_elasticsearch.py -h

usage: load_csv_or_json_to_elasticsearch.py [-h] [--es_host ES_HOST]
[--es_id_field ES_ID_FIELD]
[--es_id_start_from ES_ID_START_FROM]
[--delete_index_first {True,False}]
input_file es_index_name

Load data from CSV file or newline delimited JSON file to a running Elasticsearch cluster.

positional arguments:
input_file Path to the input csv/json file. Extension check on .csv or .json/.log
es_index_name Name of the index in which to index the documents.

optional arguments:
-h, --help show this help message and exit
--es_host ES_HOST Hostname and port of an Elasticsearch node. Defaults to 'localhost:9200'.
--es_id_field ES_ID_FIELD Field consisting unique id of the document/row. If reserved field (_id) present it gets dropped if not specified by this argument.
--es_id_start_from ES_ID_START_FROM Starting id number if no index_field is provided. Defaults to 1.
--delete_index_first {True,False} Whether to clear the index first before loading new data.

Example:

python3 load_csv_or_json_to_elasticsearch.py my-data.csv my-elastic-index

About


Languages

Language:Python 100.0%