Search code examples
elasticsearchopensearchamazon-opensearch

Version of OpenSearch that created the index


I recently upgraded AWS OpenSearch 1.3 to 2.5. All of the indices were created with 1.3 and new indices will be created with 2.5. According to the OpenSearch upgrade guide, nodes and indices are backward-compatible with the previous major version: https://opensearch.org/docs/2.0/install-and-configure/upgrade-opensearch/index/.

The next time I upgrade to OpenSearch 3.x, I need to reindex all 1.3 indices to 2.5 before the upgrade can happen without risking incompatibility. I could reindex them now to 2.5 but there is no need to as they (many) are time-series and possibly deleted then. However there could be a chance that some of 1.3 indices would still be around. How do I know which is which?

Anyone has further information, please share.

The research I've done so far is:

GET /some_index/_settings

{
    "some_index": {
        "settings": {
            "index": {
                "creation_date": "1655146986159",
                "number_of_shards": "5",
                "number_of_replicas": "1",
                "uuid": "vsSCEn6XSgCCB2tn0eWVUg",
                "version": {
                    "created": "135238227"
                },
                "provided_name": "some_index"
            }
        }
    }
}

Nowhere it says 2.5:

GET /

{
    "name": "2043c84f0bd1df9061a44af7a05b5f30",
    "cluster_name": "some_cluster",
    "cluster_uuid": "OZvWRYh7SSemqAsvl-dW8w",
    "version": {
        "number": "7.10.2",
        "build_type": "tar",
        "build_hash": "unknown",
        "build_date": "2023-03-22T09:38:59.330594Z",
        "build_snapshot": false,
        "lucene_version": "9.4.2",
        "minimum_wire_compatibility_version": "7.10.0",
        "minimum_index_compatibility_version": "7.0.0"
    },
    "tagline": "The OpenSearch Project: https://opensearch.org/"
}

My thought is that .index.version.created indicates the version of OpenSearch that created the index but I don't know how to interpret beyond the first 2 digits. Interestingly the new index created with 2.5 has "created": "136267827".

It's quite easy to interpret ElasticSearch .index.version.created: https://discuss.elastic.co/t/which-version-of-es-was-an-index-created-with/157904


Solution

  • You're on the right path with the index.version.created value. However, looking at the source code, this value needs to undergo a small arithmetic operation (bitwise XOR) in order to figure out what it is, i.e. you need to mask it with 0x08000000.

    So:

    135238227 ^ 0x08000000 = 1020499 => Opensearch 1.2.4

    136267827 ^ 0x08000000 = 2050099 => Opensearch 2.5.0