0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

I tried the following curl -X PUT "localhost:9200/myindex/_mapping/systemChanges" -H 'Content-Type: application/json' -d' { "properties": { "changed": { "enabled": true } } } The result was {"acknowledged":true} . Then after checking the same I can see the changed field is still in enabled:false status
I think it’s because as seen in your first query block in your issue description you have the disabled the entire mapping type.
I tried to enable the same as curl -X PUT "localhost:9200/myindex/_mapping/systemChanges" -H 'Content-Type: application/json' -d' { "_all": { "enabled": true } }' But unfortunately I'm getting the following error {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"mapper [_all] enabled is false now encountering true"}],"type":"illegal_argument_exception","reason":"mapper [_all] enabled is false now encountering true"},"status":400}
You can update enabled setting on existing fields. I dont believe you can use the update setting on entire mapping type unfortunately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.