【问题标题】:Setting enabled to true Elasticsearch将启用设置为真 Elasticsearch
【发布时间】:2019-03-24 23:56:49
【问题描述】:

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

{
    "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", "reason":"已经存在","index":"myindex"},"status":400}

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

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

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

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

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

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

    【讨论】:

    • 我尝试了以下curl -X PUT "localhost:9200/myindex/_mapping/systemChanges" -H 'Content-Type: application/json' -d' { "properties": { "changed": { "enabled": true } } },结果是{"acknowledged":true}。然后在检查相同的内容后,我可以看到更改的字段仍处于启用状态:false 状态
    • 我认为这是因为在您的问题描述中的第一个查询块中可以看到,您禁用了整个映射类型。
    • 我尝试启用与curl -X PUT "localhost:9200/myindex/_mapping/systemChanges" -H 'Content-Type: application/json' -d' { "_all": { "enabled": true } }'相同的功能,但不幸的是我收到以下错误{"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}
    • 您可以更新现有字段的启用设置。不幸的是,我不相信您可以在整个映射类型上使用更新设置。
    猜你喜欢
    • 2012-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-26
    • 2020-01-08
    • 2014-05-14
    • 2016-12-14
    相关资源
    最近更新 更多