olivere / elastic

Deprecated: Use the official Elasticsearch client for Go at https://github.com/elastic/go-elasticsearch
https://olivere.github.io/elastic/
MIT License
7.42k stars 1.15k forks source link

ScrollService return `io.EOF` error when no hits in the response. #1607

Closed orangemi closed 2 years ago

orangemi commented 2 years ago

Please use the following questions as a guideline to help me answer your issue/question without further inquiry. Thank you.

Which version of Elastic are you using?

[ ] elastic.v7 (for Elasticsearch 7.x) [ ] elastic.v6 (for Elasticsearch 6.x) [x] elastic.v5 (for Elasticsearch 5.x) [ ] elastic.v3 (for Elasticsearch 2.x) [ ] elastic.v2 (for Elasticsearch 1.x)

Please describe the expected behavior

When a scrollService response with no hits in the result, it will return io.EOF error. It make no sense no hits is a EOF error and I don't think it is an error either.

I think the driver should return the response without any error when hits is an empty array.

When I turn on the traceLog, the es server response status is 200.

POST /soa_org_member/member/_search?scroll=5m&size=100 HTTP/1.1
Host: HIDDEN_HOSTNAME:9200
User-Agent: elastic/5.0.79 (darwin-amd64)
Transfer-Encoding: chunked
Accept: application/json
Authorization: Basic HIDDEN
Content-Type: application/json
Accept-Encoding: gzip

*** hidden POST BODY ***

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8

{"_scroll_id":"HIDDEN SCROLL ID","took":94,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

Please describe the actual behavior

I found this line of code here related: https://github.com/olivere/elastic/blob/29ee98974cf1984dfecf53ef772d721fb97cb0b9/scroll.go#L438-L440

Any steps to reproduce the behavior?

olivere commented 2 years ago

That's the way it is since, I think, v2. Also, v5 is no longer supported. And even if it were, this is a breaking change that has the potential to impact hundreds or thousands of apps. I'm not going to do that.