首页 > 解决方案 > Elasticsearch:缺少 Content-Type 标头

问题描述

我正在使用 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

我正在摄取 AWS Config 快照的 json 文件。

标签: pythonelasticsearch

解决方案


从 ES 6.0 开始Content-Type 标头是强制性的。如果您使用的是这个脚本,那么前面提到的elasticsearchpython 库不会改变任何东西,因为这个脚本不使用这个库。

作为一种解决方法,您可以使用 AWS Elasticsearch 5.6(在您弄清楚如何发送 Content-Type 标头之前应该可以使用)。如果您可以编辑脚本,请考虑手动设置标题(可以在此处找到很好的示例)。另请参阅此答案

希望有帮助!


推荐阅读