【问题标题】:Disable date detection in Tire's elasticsearch mapping在轮胎的弹性搜索映射中禁用日期检测
【发布时间】:2013-02-11 13:51:21
【问题描述】:

我正在索引具有属性obj_properties 的文档,该属性是属性名称-> 属性值的散列。 elasticsearch 推断某些属性值是日期,当遇到无法解析为日期的同一属性的后续值时,会导致以下错误。

org.elasticsearch.index.mapper.MapperParsingException: failed to parse date field <NON-DATE FIELD within obj_properties>

所以,我想禁用 obj_properties 以及其中嵌套的任何内容的日期检测。每

http://elasticsearch-users.115913.n3.nabble.com/Date-Detection-not-always-wanted-tp1638890p1639415.html

(请注意,我认为链接的帖子包含错字——该字段应为date_formats 而不是date_format,但我已尝试两种方式)

我创建了以下映射

mapping do
    indexes :name
    indexes :obj_properties, type: "object", date_formats: "none"
  end

但我继续收到同样的异常。 obj_properties 中的属性无法提前知道,因此无法创建详尽的类型映射。有任何想法吗?禁用日期检测是正确的方法吗?

【问题讨论】:

    标签: elasticsearch tire


    【解决方案1】:

    您可以通过在映射中指定特定type 来关闭日期检测:

    curl -XPUT 'http://127.0.0.1:9200/myindex/?pretty=1'  -d '
    {
       "mappings" : {
          "mytype" : {
             "date_detection" : 0
          }
       }
    }
    '
    

    或通过在默认映射中指定索引中的所有类型:

    curl -XPUT 'http://127.0.0.1:9200/myindex/?pretty=1'  -d '
    {
       "mappings" : {
          "_default_" : {
             "date_detection" : 0
          }
       }
    }
    '
    

    【讨论】:

      【解决方案2】:
      mapping(date_detection: false) do
        indexes :name
        indexes :obj_properties, type: "object"
      end
      

      那么curl 'http://127.0.0.1:9200/myindex/_mapping?pretty=1' 将包括date_detection = false 提到的here

      虽然我相信这适用于整个索引 - 而不是特定字段

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-08-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-02-14
        • 1970-01-01
        • 2012-03-13
        • 1970-01-01
        相关资源
        最近更新 更多