Elasticsearch搜索异常-------org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper: parse_exception
2024-10-23 16:02:12
异常问题:
Caused by: org.elasticsearch.index.query.QueryShardException: Failed to parse query [LOL: Uzi和Mlxg偶遇飞机故障, 二人被赶下飞机, Uzi句话暴露关系!]
at org.elasticsearch.index.query.QueryStringQueryBuilder.doToQuery(QueryStringQueryBuilder.java:1042) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:96) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.index.query.BoolQueryBuilder.addBooleanClauses(BoolQueryBuilder.java:444) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.index.query.BoolQueryBuilder.doToQuery(BoolQueryBuilder.java:418) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:96) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.index.query.QueryShardContext.lambda$toQuery$1(QueryShardContext.java:313) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:325) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:312) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:617) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.search.SearchService.createContext(SearchService.java:485) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:461) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.search.SearchService.executeDfsPhase(SearchService.java:226) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.action.search.SearchTransportService$5.messageReceived(SearchTransportService.java:332) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.action.search.SearchTransportService$5.messageReceived(SearchTransportService.java:329) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:644) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:638) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-5.6.9.jar!/:5.6.9]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_172]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_172]
... 1 common frames omitted
Caused by: org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper: parse_exception: Cannot parse 'LOL: Uzi和Mlxg偶遇飞机故障, 二人被赶下飞机, Uzi句话暴露关系!': Encountered "<EOF>" at line 1, column 40.
Was expecting one of:
<BAREOPER> ...
"(" ...
"*" ...
<QUOTED> ...
<TERM> ...
<PREFIXTERM> ...
<WILDTERM> ...
<REGEXPTERM> ...
"[" ...
"{" ...
<NUMBER> ...
<TERM> ...
"*" ...
1.异常原因
在搜索的时候没有对搜索的内容进行转义。
String intro = infomationSearchReqVO.getIntro();
//转义特殊字符
String searchIntro = QueryParser.escape(intro);
官方文档上写的很清楚,获取一个被转义后的字符串。
escape
public static String escape(String s)
Returns a String where those characters that QueryParser expects to be escaped are escaped by a preceding \.
返回一个String,其中QueryParser期望被转义的那些字符被前面的转义\
。
最新文章
- .NET跨平台之运行与Linux上的Jexus服务器
- 超好用的网页栅格化工具: GridGuide
- js正则表达式校验非负整数:^\d+$ 或 ^[1-9]\d*|0$ 【转载】
- java web中jsp,action,service,dao,po分别是什么意思和什么作用
- jdk 与jre的区别
- CMS收集器
- PHP文章管理(2)
- activity的生命周期【转】
- nodejs文件操作模块FS(File System)常用函数简明总结(转)
- JAVA_SE基础——63.String类的常用方法
- 必须知道的Java八大排序算法
- Netty(一) SpringBoot 整合长连接心跳机制
- 树莓派中学TensorFlow
- 鼠标 DPI与CPI
- 在Virtualenv中使用Idle
- svn目标计算机主动拒绝
- 实现multibandblend
- 118. Pascal&#39;s Triangle (Array)
- CentOS下调整home和根分区大小的方法
- Major Performance Impacts