【问题标题】:Elastic Search bulk index fails with date detection off弹性搜索批量索引失败,日期检测关闭
【发布时间】:2015-11-08 14:40:20
【问题描述】:
DELETE /rosetta_account

POST /rosetta_account/account_number
{
      "settings" : {
        "number_of_shards" : 20,
        "number_of_replicas" : 2,
        "index_analyzer" : "standard",
        "search_analyzer" : "standard",
         "date_detection" : false
    }
}

curl -s -XPOST localhost:9200/rosetta_account/account_number/_bulk --data-binary @data.file


{"took":68,"errors":true,"items":[{"create":{"_index":"rosetta_account","_type":"account_number","_id":"123456789","status":400,"error":"WriteFailureException; nested: MapperParsingException[failed to parse [customer_upgrade_dt]]; nested: MapperParsingException[failed to parse date field [], tried both date format [dateOptionalTime], and timestamp number with locale []]; nested: IllegalArgumentException[Invalid format: \"\"]; "}}

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    根据你得到的错误:

    failed to parse [customer_upgrade_dt] ... 
    tried both date format [dateOptionalTime], and timestamp number with locale ...
    Invalid format: \"\"
    

    这意味着在您包含在data.file 中的一个 JSON 文档中,您有一个名为 customer_upgrade_dt 的字段,其值为空字符串 "",如果该字段无效,则该字段对于日期字段无效有任何值,您要么需要将其设置为null,要么根本不将该字段包含在文档中。很明显,日期仍在检测中。

    原因是因为您在索引设置中将 date_detection 设置为 false,但这不是放置该参数的正确位置,您需要将其添加到映射中而不是索引设置中,即创建索引改为这样:

    POST /rosetta_account/account_number
    {
        "settings" : {
            "number_of_shards" : 20,
            "number_of_replicas" : 2,
            "index_analyzer" : "standard",
            "search_analyzer" : "standard"
        },
        "mappings": {
          "account_number": {
            "date_detection": false
          }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-28
      • 2016-06-20
      • 1970-01-01
      • 1970-01-01
      • 2018-04-07
      • 2013-10-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多