代码之家  ›  专栏  ›  技术社区  ›  ExploringApple

Elasticsearch:缺少内容类型标题

  •  0
  • ExploringApple  · 技术社区  · 7 年前

    我使用python 2.7在AWS Elasticsearch(v 6.3)中摄取数据,在添加数据(json)时得到

    response: {"error":"Content-Type header is missing","status":406}...message: {"error":"Content-Type header is missing","status":406}
    

    pip install elasticsearch .

    1 回复  |  直到 7 年前
        1
  •  2
  •   Nikolay Vasiliev    7 年前

    从ES 6.0开始 Content-Type header is obligatory . 如果你正在使用 this script elasticsearch 由于此脚本不使用此库,因此python库不会更改任何内容。

    作为一种解决方法,您可以使用AWS Elasticsearch 5.6(应该可以工作,直到您找到如何发送内容类型头)。如果可以编辑脚本,请考虑手动设置头(可以找到很好的示例 here this answer .