gpt4 book ai didi

elasticsearch - ElasticSearch无法识别定义了编码的Context-Type header

转载 作者:行者123 更新时间:2023-12-03 00:05:01 25 4
gpt4 key购买 nike

我花了一些时间尝试修复 flex 搜索批量上传警告:

Content type detection for rest requests is deprecated. Specify the content type using the [Content-Type] header



我的要求如下:
POST http://elasticserver/_bulk HTTP/1.1
Authorization: xxx
Content-Type: application/x-ndjson; charset=utf-8
Host: elasticserver
Content-Length: 8559

... new line delimited json content ...

我的200位有效回复如下:
HTTP/1.1 200 OK
Warning: 299 Elasticsearch-5.5.1-19c13d0 "Content type detection for rest requests is deprecated. Specify the content type using the [Content-Type] header." "Mon, 14 Aug 2017 00:46:21 GMT"
content-type: application/json; charset=UTF-8
content-length: 4183

{"took":5538,"errors":false,...}

通过实验,我发现问题出在内容类型字符集定义 Content-Type: application/x-ndjson; charset=utf-8中,如果将其更改为 Content-Type: application/x-ndjson,则不会收到任何警告。

是 flex 搜索问题,还是我的请求格式不正确?

最佳答案

official documentation明确指出

When sending requests to this endpoint the Content-Type header should be set to application/x-ndjson.



RestController source code还表明他们忽略了字符集:
final String lowercaseMediaType = restRequest.header("Content-Type").toLowerCase(Locale.ROOT);
// we also support newline delimited JSON: http://specs.okfnlabs.org/ndjson/
if (lowercaseMediaType.equals("application/x-ndjson")) {
restRequest.setXContentType(XContentType.JSON);
return true;
}

关于elasticsearch - ElasticSearch无法识别定义了编码的Context-Type header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45666171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com