【问题标题】:How to solve this "Content type detection for rest requests is deprecated" issue of elastisearch?如何解决elasticsearch的“不推荐使用休息请求的内容类型检测”问题?
【发布时间】:2017-10-07 07:01:20
【问题描述】:

我的 Elasticsearch 服务器中有很多日志,而这个日志占用了太多磁盘内存。每 2-3 小时,服务器会获取大约 4 GB 的日志。

日志看起来像-

[2017-05-08T03:08:14,616][WARN][o.e.d.r.RestController ] 不推荐使用休息请求的内容类型检测。使用 [Content-Type] 标头指定内容类型

【问题讨论】:

  • Specify the content type using the [Content-Type] header => 与您的 ES 服务器交互的客户端之一没有发送 Content-Type: application/json 标头,因为 ES 不再自动检测内容。
  • 是不是因为API的变化?
  • 你用的是哪个ES版本?

标签: elasticsearch logging logstash


【解决方案1】:

对于那些使用 curl 的人,一个简单的添加

-H 'Content-Type: application/json'

帮我搞定了

【讨论】:

    【解决方案2】:

    更新我的客户,在我的例子中,elasticsearch-model 和 elasticsearch-rails 为我解决了这个问题。

    【讨论】:

      【解决方案3】:

      我通过在创建 HttpEntity 时指明 contentType 来解决这个问题:

      ContentType contentType = ContentType.create("application/json", "UTF-8");
      HttpEntity entity = new StringEntity(jsonString, contentType)
      

      【讨论】:

        猜你喜欢
        • 2020-01-16
        • 2019-10-18
        • 2020-05-09
        • 2021-03-03
        • 1970-01-01
        • 2020-10-23
        • 1970-01-01
        • 1970-01-01
        • 2020-06-18
        相关资源
        最近更新 更多