Elasticsearch version
bin/elasticsearch --version
7.6.0
Problem
I use go-elasticsearch client query from elasticsearch.
resp, err := client.Search(
client.Search.WithContext(d.ctx),
client.Search.WithIndex(index),
client.Search.WithBody(body),
client.Search.WithTimeout(timeout), // 200ms
client.Search.WithPreference(preference),
client.Search.WithRouting(routing...),
)
the query body is just ids query
{
"query": {
"ids": {
"values": [
"123"
]
}
},
"size": 1
}
but the ES return empty result with timeout:true
{
"_shards": {
"failed": 0,
"skipped": 0,
"successful": 20,
"total": 20
},
"hits": {
"hits": [
],
"max_score": null,
"total": {
"relation": "eq",
"value": 0
}
},
"timed_out": true,
"took": 1
}
the took=1ms , and the caller time i record is also 1ms, this means the ES server give me the response in 1ms after i send the request to the server .
But the timeout i set is 200ms .
The probability of this happening is very low and cannot be reproduced
Sorry for bother you
dadoonet
(David Pilato)
January 6, 2023, 7:23am
3
I have no idea. But why are you setting such a timeout in the first place?
I'd definitely upgrade to the latest 7.17.8 version (or 8.5.3). This one is a way too old.
1 Like
Thank you so much for your reply
But why are you setting such a timeout in the first place?
Because if the ES server return very slow, i will discard the results from ES
I'd definitely upgrade to the latest 7.17.8 version (or 8.5.3). This one is a way too old.
ES cluster are uniformly maintained by a dedicated team, and it is difficult to upgrade directly
I have currently escaped this issue by retry once if the response is empty and timeout=true
dadoonet
(David Pilato)
January 6, 2023, 7:41pm
6
In which case you are basically doubling the timeout value.
Question is: why not doubling it?
I mean that setting a timeout is not going to speed up your queries.
1 Like
Oh, I get what you said.
I want to say that the problem is not because of the timeout value is not enough. I set 200ms, but ES server just use 1ms and give me an empty response.
dadoonet
(David Pilato)
January 9, 2023, 2:45pm
8
Does this happen when you don't set any timeout?
1 Like
Thank you for your advice, you mean that this timeout
param may have some bad effect on this problem?
I will try this way next time. Thank you!
system
(system)
Closed
February 7, 2023, 7:02am
10
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.