【问题标题】:How to detect whether elasticsearch has enabled dynamic field如何检测elasticsearch是否启用了动态字段
【发布时间】:2021-12-14 10:06:13
【问题描述】:

我不知道我的索引是否启用/禁用了动态字段。当我使用 get index mapping 命令时,它只会响应这些信息:

GET /my_index1/_mapping
{
    "my_index1": {
        "mappings": {
            "properties": {
                "goodsName": {
                    "fields": {
                        "keyword": {
                            "ignore_above": 256,
                            "type": "keyword"
                        }
                    },
                    "type": "text"
                },
                "auditTime": {
                    "type": "long"
                },
                "createUserId": {
                    "type": "long"
                }
            }
        }
    }
}

【问题讨论】:

    标签: elasticsearch mapping


    【解决方案1】:

    如果您没有将dynamic 显式设置为falsestrict,则默认为true。如果您明确设置,您将在映射中看到:

    {
        "mappings": {
            "dynamic": false,
            "properties": {
                "name": {
                    "type": "text"
                }
            }
        }
    }
    

    当您索引以下文档时:

    {"name":"products", "clickCount":1, "bookingCount":2, "isPromoted":1}
    

    只有字段name 会被索引,其余的不会。如果您再次调用_mapping 端点,它将为您提供上面的确切映射。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-20
      • 1970-01-01
      • 1970-01-01
      • 2015-10-21
      • 1970-01-01
      相关资源
      最近更新 更多