Elasticsearch java Client 分页时连接关闭问题

最近在做一个es 深度钻取功能,对源数据查询es默认分页时10条,于是做了一个分页界面,Client 写成单例模式了,每次返回时关闭client.close() 就会出现bug:
NodeAvailableException[None of the configured nodes are available: [{#transport#-1}{192.168.170.69}{192.168.170.69:9300}]]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:290)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:207)
at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:288)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56)


不关闭虽然用了同一个实例,避免了每次请求,新生成新的实例,但是考虑连接总要关闭的,不知道有没有好的解释和办法?

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!