有没有办法知道Elasticsearch中键的数据类型?

有没有办法知道Elasticsearch中键的数据类型?,
Warning: implode(): Invalid arguments passed in /data/phpspider/zhask/webroot/tpl/detail.html on line 45
,,我面临着像密钥的数据类型被更改这样的问题。在创建索引时,我将数据类型设置为嵌套,但由于某种原因,它会更改为object。我通过无痛脚本进行CRUD操作,但这似乎很好 弹性版本7.3.0 初始模板: "settings": { "number_of_shards": 1, }, "mappings" : { "properties": { "deleted_at": { "

我面临着像密钥的数据类型被更改这样的问题。在创建索引时,我将数据类型设置为嵌套,但由于某种原因,它会更改为object。我通过无痛脚本进行CRUD操作,但这似乎很好

弹性版本7.3.0

初始模板:

"settings": {
  "number_of_shards": 1,
},
"mappings" : {
  "properties": {
    "deleted_at": { "type": "date" },
    "updated_at": { "type": "date" },
    "id": { "type": "integer" },
    "user_id": { "type": "integer" },

    ... some more keys

    "user_tags": {
      "type": "nested"
    },
    "user_files": {
      "type": "nested"
    },
  }
}
批量插入/更新后的映射

"mappings" : {
  "properties": {
    "deleted_at": { "type": "date" },
    "updated_at": { "type": "date" },
    "id": { "type": "integer" },
    "user_id": { "type": "integer" },
    "user_tags": {
      "properties": {
        ...some properties
      }
    },
    "user_files": {
      "properties": {
        ...some properties
      }
    },
  }
}
我必须重新编制索引来解决这个问题,但这种情况经常发生。还有什么方法可以知道键的数据类型是嵌套的还是对象的

提前感谢。

通过设置
“dynamic”:“strict”
您的映射不会更改,也不会插入不合适的文档。要解决此问题,您需要定义要位于嵌套字段内部的所有字段。例如:

{
"user_tags": {
            "type": "nested",
            "properties": {
              "code": {
                "type": "keyword",
                "store": true
              },
              "score": {
                "type": "float",
                "store": true
              }
              
            }
          }
}
如果您只想存储一个列表,可以使用如下映射:

{
    "user_tags": {
            "type": "keyword",
            "store": true
          }
}
在第二个映射中,您可以使用此结果存储用户标记
[“tag1”、“tag2”、…]