sreelakshmi
sreelakshmi

Reputation: 274

Setting enabled to true Elasticsearch

I'm new to elasticsearch. I have an index type as follows

{
    "myindex" : {
        "mappings" : {
            "systemChanges" : {
                "_all" : {
                    "enabled" : false
                },
                "properties" : {
                    "autoChange" : {
                        "type" : "boolean"
                    },
                    "changed" : {
                        "type" : "object",
                        "enabled" : false
                     },
                    "created" : {
                        "type" : "date",
                        "format" : "strict_date_optional_time||epoch_millis"
                    }
                }
            }
        }
    }
}

I'm unable to fetch the details having changed.new = completed. After some research i have found that it's because the changed field is set to enabled : false. and I need to change the same. I tried as follows

curl -X PUT "localhost:9200/myindex/" -H 'Content-Type: application/json' -d' {
    "mappings": {
        "systemChanges" : {
            "properties" : {
                "changed" : {
                    "enabled" : true
                }
            }
        }
    }
}'

But I'm getting error as following.

{"error":{"root_cause":[{"type":"index_already_exists_exception","reason":"already exists","index":"myindex"}],"type":"index_already_exists_exception","reason":"already exists","index":"myindex"},"status":400}

How can I change the enabled to true in order to fetch the details of the changed.new field?

Upvotes: 0

Views: 2237

Answers (1)

ben5556
ben5556

Reputation: 3018

you are trying to add an index again with the same name and hence the error.

See the below link for updating a mapping

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html

The enabled setting can be updated on existing fields using the PUT mapping API.

Upvotes: 1

Related Questions