Elasticsearch Reindex in Python

Introduction

--It is recommended to insert using the Bulk API when you want to recreate a certain index (= reindex). Since it's not a production environment in particular, I didn't need to use Alias, so I checked the memo when I implemented it with the Python API.

Elasticsearch

Verification

-Read Speed up ElasticSearch indexing before putting it in Bulk. It was very helpful. --Set replica shard to 0 --Change the commit frequency --Disable _all field

Create a new Index

--Enter the number of shards you forgot to set in the previous index and the mapping correctly.

PUT 'XXX.XXX.XXX.XXX:9200/[new index]' -d '
index :
    number_of_shards : 3
    number_of_replicas : 0
'

Bulk API (in Python)

Read the documentation for Helpers. It seems that it can be done with the following feeling.

from elasticsearch import Elasticsearch
from elasticsearch import helpers
es = Elasticsearch(host="XXX.XXX.XXX.XXX", port=9200)
helpers.reindex(es, source_index = "old-index", target_index = "new-index")

It is recommended to put about 10MB each in the index size. From the reference below. Reference: Considerations for Elasticsearch indexing performance

in conclusion

-Bulk API I'm glad it was easy.

reference

Recommended Posts

Elasticsearch Reindex in Python
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
SendKeys in Python
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Flatten in python
flatten in python
Sorted list in Python
Daily AtCoder # 36 in Python
Clustering text in Python
Daily AtCoder # 2 in Python
Implement Enigma in python
Daily AtCoder # 32 in Python
Daily AtCoder # 6 in Python
Daily AtCoder # 18 in Python
Edit fonts in Python
Singleton pattern in Python
File operations in Python
Read DXF in python
Daily AtCoder # 53 in Python
Key input in Python
Use config.ini in Python
Daily AtCoder # 33 in Python
Solve ABC168D in Python
Logistic distribution in Python