1.IndexMissingException
异常信息如下:
org.elasticsearch.indices.IndexMissingException: [esfindexa] missing
at org.elasticsearch.cluster.metadata.MetaData.convertFromWildcards(MetaData.java:867)
at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:684)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.<init>(TransportSearchTypeAction.java:118)
异常原因:要查询的索引esfindexa不存在;
解决办法:可以直接抛掉或者返回用户要查询的索引不存在;
2.NoNodeAvailableException: No node available
检查操作java API的客户端的ES的jar包版本是否与服务上的一致;
参考:
http://stackoverflow.com/questions/23520684/elasticsearch-java-apinonodeavailableexception-no-node-available
3.QueryParsingException
一、Query转化异常(包含特殊字符)
异常信息:
"fields":{"DESCRIPTION":{}}}}]]]; nested: QueryParsingException[[fy] Failed to parse query [春华四"季园]];
nested: ParseException[Cannot parse '春华四"季园': Lexical error at line 1, column 7.
Encountered: <EOF> after : "\"\u5b63\u56ed"];
nested: TokenMgrError[Lexical error at line 1, column 7. Encountered: <EOF> after : "\"\u5b63\u56ed"]; }
原因:
使用query_String 查询时包含了特殊字符,
query.must(QueryBuilders.queryStringQuery( “春华四\”季园”)
.field(“DESCRIPTION”));
解决方法:
使用lucene的phrase函数进行转义,
query.must(QueryBuilders.queryStringQuery(
QueryParser.escape(“春华四\”季园”)).field(“DESCRIPTION”));
4.DocumentMissingException
异常信息:
Caused by:
org.elasticsearch.index.engine.DocumentMissingException: [esfindex][0] [esftype][4223]: document missing
at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:83)
at
原因:
更新的记录已经不存在
解决:
更新之前先进行判断,看指定ID的文档是否存在,然后再更新
**5.EsRejectedExecutionException[re**jected execution (queue capacity
org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [query], all shards failed;
shardFailures {[ZuFh0n4mQHu3PqOLHZp08w][fy][0]: EsRejectedExecutionException[rejected execution (queue capacity 1000)
on org.elasticsearch.search.action.SearchServiceTransportAction$23@16b28576]}{[ZuFh0n4mQHu3PqOLHZp08w][fy][1]:
查询请求超出最大队列限制,如果想支持超过1000的,可以修改配置文件的线程池设置: