5

Is there any way to know which Elasticsearch version a particular index was created in?

This is mainly useful when you want to upgrade your cluster and there might be older indices which need to be reindexed to a newer version prior to upgrade the cluster to avoid incompatibility issues.

For example, if we want to upgrade to version 7.5, if we have indices created in 5.x or before, we need to reindex or delete them before upgrading to 7.5.0. Elasticsearch nodes will fail to start if incompatible indices are present. Snapshots of 5.x or earlier indices cannot be restored to a 7.x cluster even if they were created by a 6.x cluster (https://www.elastic.co/guide/en/elasticsearch/reference/current/reindex-upgrade.html).

ernirulez
  • 671
  • 1
  • 9
  • 20

3 Answers3

7

There are two simple calls we can make to know this:
- GET my_index?human
- GET my_index/_settings?human

In both calls, you will find in the response something like this:

"version" : {
    "created_string" : "7.4.2",
    "created" : "7040299"
}

The created field indicates the release build. The created_string field appears only if you include the ?human flag for a clearer view.

ernirulez
  • 671
  • 1
  • 9
  • 20
1

I wrote this bash script to get the version of every single index:

#!/bin/bash

INDICES=$(curl --silent "localhost:9200/_cat/indices?h=index")

for INDEX in $INDICES; do

 if [[ "$INDEX" == *geoip* ]]; then
  continue
 fi

 VERSION=$(curl --silent "localhost:9200/$INDEX/_settings?pretty" | grep "created" | cut -d'"' -f4)
 echo "Index: '$INDEX', version: '$VERSION'"

done

Hope this help someone. This script helps me to search for old index versions in the upgrade process of Elasticsearch from 7 to 8.

Julian Rios
  • 2,431
  • 2
  • 7
  • 9
0

you can fetch all indexes version with one api call:

curl -s http://localhost:9200/_all/_settings?pretty
Fedor
  • 17,146
  • 13
  • 40
  • 131
bbezak
  • 1