I have a small index (~10000 documents) and have specified 1000 as the argument to the size() method of SearchSourceBuilder. When I inspect the totalHits value for some of my searches, that number is in excess of the size limit I've set so I increased it to a larger number, say, 5000. However, when I do that, the searches fail with a SocketTimeout exception. So, I set a value of 120 seconds as the timeout, which should be more than enough to complete the query, yet it still fails with a SocketTimeout. What am I missing here? Is there some setting on the Elasticsearch server which I need to modify in order to keep the handshake alive? I am working with the Elasticsearch service hosted in AWS. Also, my code is in Java.
Okay, I am writing in Java, but this code gives me a hint! I will try setting the timeout on both the client call and the search request. I may not get to it today, since I have another fire to put out. But I will report back next week. Thanks for taking the time to code this up!
Okay, I took a quick look at the 6.8 docs (which is the version I'm using) and there doesn't appear to be any way to set the socket timeout, just maxRetries. There is some code which shows how to set the callback but I don't think that is what I want. Looks like I'm stuck at this point with being able to configure the client with a different socket timeout value. Any other thoughts would be appreciated.
I can't change the timeout for the client, there is no method to do that, at least none that I could see. I can set the timeout in the SearchSourceBuilder but that doesn't seem to make a difference.
okay, that makes sense. We actually have lombok in our project but not using it in this way. I will try your code and see if that works. Should I also set the timeout on the call to the client? As I described before?
Well, it turns out that my team lead is no longer "hot" on the issue of fixing the timeout. He is satisfied if the result set is capped at 1000 even though there may be significantly more than that returned as hits. I'll keep this in my back pocket should things change but I appreciate the time and effort you put into helping me out.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.