【问题标题】:Elasticsearch Dynamic template not working as requiredElasticsearch 动态模板未按要求工作
【发布时间】:2018-09-12 04:17:22
【问题描述】:

我想要一个具有一些预定义字段(包括对象类型字段)的弹性搜索架构。我希望该对象类型字段中的所有字段默认为字符串。

我在创建索引时有以下映射和动态模板。

PUT myindex
{
  "mappings": {
    "doc": {
      "dynamic_templates": [
        {
          "default_string": {
            "path_match": "myObj.*",
            "match_mapping_type": "*",
            "mapping": {
              "type": "text"
            }
          }
        }],
      "properties": {
        "dummy_field_name": { "type": "text" },
        "timestamp": {
          "type": "date",
          "format": "epoch_second"
        },
        "myObj": {
          "type": "object"
        }
      }
    }
  }
}

但是当我在对象内提交一个带有数值的字段时,它并没有将该字段映射到字符串。

curl -XPOST "http://elastic-url:8080/myindex/test" -d 
'{"dummy_field_name": "dymmy_value", "myObj":{ "filed_1": 123 , 
"field_2": "some value"}, "timestamp": 1522196333}'

“filed_1”被标识为数字字段。但我希望它存储为字符串类型。

Field types detected

【问题讨论】:

    标签: elasticsearch kibana elasticsearch-5


    【解决方案1】:

    您的映射是为“doc”类型定义的,但您正在索引类型“test”,请尝试匹配它们

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多