1
votes

Well, say that I have an elasticsearch index which is updated rarely. I need to change the version of it every time an update happens.

For example: First I create the index

PUT /test_index
{
    "settings": {
        "number_of_shards": 3,
        "number_of_replicas": 1 },
    "mappings": {
        "student_data": {
            "properties": {
                "name": {"type": "keyword" },
                "grade": { "type": "float" },
                "created_date": { "type": "float"}
            }
        }
    }
}

After creation of the created index settings I get

"settings": {
    "index": {
        "creation_date": "1549622658089",
        "number_of_shards": "3",
        "number_of_replicas": "1",
        "uuid": "xxxxxxxxx",
        "version": {
        "created": "6050199"
    },
    "provided_name": "test_index"
    }

What I need to to change this

"version": {"created": "6050199"}

every time I update a document in the index. Is there a way to do this? Thank you in advance.

FYI: I tried adding the version at the point of creating the index like,

PUT /test_index
{
    "settings": {
        "number_of_shards": 3,
        "number_of_replicas": 1,
        "version": 2
    },
    "mappings": {
        "student_data": {
            "properties": {
                "name": {"type": "keyword"},
                "grade": {"type": "float"},
                "created_date": {"type": "float"}
            }
        }
    }
}

But I got the error,

{ "error": {"root_cause": [{ "type": "illegal_argument_exception", "reason": "unknown setting [index.version] please check that any required plugins are installed, or check the breaking changes documentation for removed settings" }], "type": "illegal_argument_exception", "reason": "unknown setting [index.version] please check that any required plugins are installed, or check the breaking changes documentation for removed settings" },"status": 400}

1

1 Answers

0
votes

Version created refer to the elasticsearch version who created the index. You cant change it like that and you have no reason to do it.

If you upg your elasticsearch version, reindex your index with the new version the version created will be upd too.

Edit: If you want a custom field in index-type level use meta-field: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-meta-field.html