首页 > 解决方案 > 将启用设置为真 Elasticsearch

问题描述

我是弹性搜索的新手。我有一个索引类型如下

{
    "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"
                    }
                }
            }
        }
    }
}

我无法获取已更改的详细信息。新 = 已完成。经过一些研究,我发现这是因为更改的字段设置为启用:false。我需要改变同样的。我尝试如下

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

但我收到以下错误。

{"error":{"root_cause":[{"type":"index_already_exists_exception","re​​ason":"已经存在","index":"myindex"}],"type":"index_already_exists_exception","re​​ason" :"已经存在","index":"myindex"},"status":400}

如何将 enabled 更改为 true 以获取 changed.new 字段的详细信息?

标签: elasticsearch

解决方案


您正在尝试再次添加具有相同名称的索引,因此出现错误。

请参阅以下链接以更新映射

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

可以使用 PUT 映射 API 在现有字段上更新启用的设置。


推荐阅读