【问题标题】:Pass update_all_types on ElasticSearch Put Mapping在 ElasticSearch 放置映射上传递 update_all_types
【发布时间】:2015-11-11 05:42:51
【问题描述】:

我们正在升级到 ElasticSearch 2.0,但在 Nest 1.7.0 中的映射遇到了问题:我们有两种类型共享一个字段(格式相同):

"@timestamp": {
            "type": "date",
            "format": "epoch_millis||dateOptionalTime"
          }

当我们尝试在启动时为其中一种受影响的类型添加映射时(我们目前每次都PUTing 映射),我们收到此错误:

{
  "error": {
    "root_cause": [{
      "type": "merge_mapping_exception",
      "reason": "Merge failed with failures {[mapper [@timestamp] is used by multiple types. Set update_all_types to true to update [format] across all types.]}"
    }],
    "type": "merge_mapping_exception",
    "reason": "Merge failed with failures {[mapper [@timestamp] is used by multiple types. Set update_all_types to true to update [format] across all types.]}"
  },
  "status": 400
}

我们正在使用描述为here 的基于代码的映射,但我没有看到在不借助我们客户端的Raw 属性的情况下使用类似这样的方法来挂起查询字符串的方法:

_client.Raw.IndicesPutMapping("ourindex", "ourtype", PutMappingDescriptorObj, parameters => parameters.AddQueryString("update_all_types", null));

我浏览了 Nest 的 2.0 branch,但没有找到对这些映射调用的 update_all_types 查询字符串参数的任何引用。

假设IndicesPutMapping() 调用可以工作,这是我们目前唯一的选择吗?我开始怀疑我们是否应该只有条件地添加这些映射。

【问题讨论】:

    标签: elasticsearch nest elasticsearch-net


    【解决方案1】:

    事实证明,我们能够找到另一种方法:当我们创建映射时,我们没有明确地为 @timestamp 字段提供格式,而 2.0 似乎导致系统将其视为更改,因此我们的问题。我们能够通过在映射逻辑中固定这些日期字段的现有格式来解决这个问题,如下所示:

    // formatted strangely to make the addition more obvious
    _client.Map<OurType>(m =>
        m.Properties(ps => ps
            .Date(d => d.Name(es => es.Date) // es is a reference to an instance of OurType, and Date is the name of the field being mapped to @timestamp
                        .Format("epoch_millis||dateOptionalTime") // this is what fixed it
                 )
            //other props
        )
        //other stuff
    );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-28
      • 2012-07-11
      • 1970-01-01
      • 2014-11-27
      • 2015-12-03
      • 2017-10-13
      • 2015-12-04
      • 2017-02-23
      相关资源
      最近更新 更多