问题
上下文
我正在进行性能调整
TransportClient的处理速度很慢
我非常麻烦。
我测量了。
通过密切处理花了2000毫秒。
public SearchResponse search(SearchParam param) {
EsConnection connect = new EsConnection();
TransportClient client = connect.getTransportClient();
try {
long start1 = System.currentTimeMillis();
response = client.prepareSearch()
.setSize(param.getNum())
.setFrom(param.getFrom())
.setQuery(shouldQuery)
.execute()
.actionGet(timeoutMsec);
System.out.println(response);
long end1 = System.currentTimeMillis();
System.err.println("search:" + (end1 - start1) + "ms");
} catch (ElasticsearchException e) {
throw e;
} finally {
long start1 = System.currentTimeMillis();
client.close();
long end1 = System.currentTimeMillis();
System.err.println("close:" + (end1 - start1) + "ms");
}
return response;
}