How can I know the Elasticsearch version an index was created in?
Asked Answered
G

4

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).

Greenwich answered 3/12, 2019 at 14:19 Comment(0)
G
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.

Greenwich answered 3/12, 2019 at 14:19 Comment(1)
ES 8.6.2. This doesn't seem to work any more. Have posted a question in the ES forum...Uxorial
F
2

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.

Fremd answered 4/2, 2023 at 19:11 Comment(0)
H
0

you can fetch all indexes version with one api call:

curl -s http://localhost:9200/_all/_settings?pretty
Hausner answered 29/8, 2023 at 17:20 Comment(0)
D
0

Another one-liner with _all/_settings and jq:

curl -s "http://localhost:9201/_all/_settings?human" | jq -r 'to_entries[] | "\(.key) - \(.value.settings.index.version.created_string)"'
Daly answered 22/8, 2024 at 15:47 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.