本文共 1666 字,大约阅读时间需要 5 分钟。
在搜索时,遇到了下面的Response:
"caused_by":{ "type":"too_many_clauses","reason":"maxClauseCount is set to 1024"}}}],"caused_by":{ "type":"query_shard_exception","reason":"failed to create query:
查询中需要对某个字段做terms搜索,传入的候选条件过多。错误代码是:
JSONObject joQuery = query( bool( must( term("user", userId), terms("keys", keyList))));
将must替换为filte即可:
JSONObject joQuery = query( bool( filter( term("user", userId), terms("keys", keyList))));
切换了新的服务器,在启动elasticsearch时,看到了下面的提示信息:
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
这个在文档里给了很详细的说明:
使用Java RestClient搜索时,出现了超时的问题:
java.io.IOException: listener timeout after waiting for [30000] ms at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:617) ~[rest-5.2.0.jar:5.2.0] at org.elasticsearch.client.RestClient.performRequest(RestClient.java:212) ~[rest-5.2.0.jar:5.2.0] at org.elasticsearch.client.RestClient.performRequest(RestClient.java:184) ~[rest-5.2.0.jar:5.2.0]
在创建RestClient时,设置超过时长:
private RestClient getClient(){ return RestClient.builder( new HttpHost(systemConfig.elasticsearchHost, Integer.parseInt(systemConfig.elasticsearchHttpPort), "http")) .setMaxRetryTimeoutMillis(5 * 60 * 1000) //超时时间设为5分钟 .build(); }
转载地址:http://hlgul.baihongyu.com/