首页 > 解决方案 > 如何处理 ElasticSearch 中的空字段名称?

问题描述

我想将用户的输入记录到我的 RESTful API 以进行调试,但只要 JSON 有效负载中有一个空字段,就会生成错误并丢弃日志。

例如,

{
  "extra": {
    "request": {
      "body": {
        "": ""
      }
    }
  }
}

...将导致

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse",
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "field name cannot be an empty string"
    }
  },
  "status": 400
}

这似乎是由https://github.com/elastic/elasticsearch/blob/45e7e24736eeb4a157ac89bd16a374dbf917ae26/server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java#L191引起的。

这有点棘手,因为它发生在解析阶段......是否有任何解决方法来删除/重命名这些字段,以便它可以使 ES 消化这些日志?

标签: elasticsearch

解决方案


推荐阅读