Migrate Elasticsearch Index to OpenSearch Index

Zakir Hossain
2 min readAug 9, 2023

--

As you already know that Elasticsearch is not open source anymore. Hence everybody looking for a good alternative, in this case OpenSearch could be a good option. Now I will share my experience how I migrate Elasticsearch-6.8.21 index into OpenSearch-2.2.0.

Environment:

Elasticsearch IP: 192.168.100.10

OpenSearch IP: 192.168.100.11

Step01: Configure OpenSearch

Open your OpenSearch configuration file and add below lines at the end of the file and and restart the service.

vim /etc/opensearch/opensearch.yml

compatibility.override_main_response_version: true

reindex.remote.whitelist: 192.168.100.10:9200 [Here IP will be ElasticSearch IP]

# systemctl restart opensearch

Step02: Check ElasticSearch Index

curl -XGET -u admin:admin “http://192.168.100.10:9200/_cat/indices?v"

You will get result as like below:

Step03: Import ElasticSearch index into Opensearch

# curl -u admin:admin -X POST "http://192.168.100.11:9200/_reindex" -H 'Content-Type: application/json' -d'

{

"source": {

"remote": {

"host": "http://192.168.100.10:9200",

"username": "admin",

"password": "admin"

},

"index": "winlogbeat-2022.10.17"

},

"dest": {

"index": "winlogbeat-2022.10.17"

}

}
'

After finish the process check the OpenSearch Indexes.

# curl -XGET -u admin:admin “http://192.168.100.11:9200/_cat/indices?v"

Hope this will help you.

You cloud try below script if you have lots of indexes.

for index in i1 i2 i3 i4 i5; do

curl -HContent-Type:application/json -XPOST localhost:9200/_reindex?pretty -d'{

"source": {

"index": "'$index'"

},

"dest": {

"index": "'$index'-reindexed"

}

}'

done

--

--

Zakir Hossain

I'm a tech enthusiast and system administrator with a focus on Open Source application and automation.