搜索结果正在快递途中

关于formXcontent的使用

Elasticsearch | 作者 401825317 | 发布于2019年12月11日 | 阅读数:2509

我遇到一个问题,我希望把一个基础的bool查询分别赋值给多个对象使用,现在不知道怎么实现深拷贝,因为boolquery没有实现序列化,所以想到了转成json,然后再转成一个新的boolquery对象,遇到了现在这个问题,这是我的实现:
TIM图片20191211105927.png

堆栈信息如下:

java.lang.NullPointerException
at org.elasticsearch.index.query.BoolQueryBuilder.fromXContent(BoolQueryBuilder.java:298)
at com.motoband.mannger.SearchManager.searchNews(SearchManager.java:1013)
at com.motoband.servlet.SearchNewsServlet.doPost(SearchNewsServlet.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
 
已邀请:

tacsklet - 公司有用到es

赞同来自: medcl

可以自己实现一个序列化的对象,然后再把这个对象解析成你要的boolquery。

Charele - Cisco4321

赞同来自:

没有理解你的意思,你直接把boolquery赋给多个对像不就行了吗?为什么要深拷贝什么的呢?

401825317 - 90后it男

赞同来自:

给出解决方案:

TIM图片20191219154110.png

 

要回复问题请先登录注册