大家好,我正在尝试构建一个搜索引擎来搜索 ES 以查找匹配项,该界面有一个动态的点击计数器,每次按键后都会更新,我正在寻找一种方法来验证、解决或捕获异常当用户使用双引号搜索时抛出,例如:
a >> 4500 hits
ab >> 1200 hits
ab" >> massive stack trace
ab"c"> 250 hits
堆栈:
2013-04-02 16:41:42,703 [New I/O worker #1] WARN transport.netty - [Jekyll] Exception caught on netty layer [[id: 0x0106148c, /xxx.xxx.xxx.xxx:xxxx => /xxx.xxx.xxx.xxx:xxxx]]
java.lang.ArrayIndexOutOfBoundsException: 54
at org.elasticsearch.common.Unicode.UTF8toUTF16(Unicode.java:190)
at org.elasticsearch.common.Unicode.unsafeFromBytesAsUtf16(Unicode.java:106)
at org.elasticsearch.common.Unicode.fromBytes(Unicode.java:80)
at org.elasticsearch.common.Unicode.fromBytes(Unicode.java:73)
at org.elasticsearch.action.count.CountRequest.toString(CountRequest.java:334)
at java.lang.String.valueOf(String.java:2854)
at java.lang.StringBuilder.append(StringBuilder.java:128)
at org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction$AsyncBroadcastAction.onOperation(TransportBroadcastOperationAction.java:306)
at org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction$AsyncBroadcastAction$3.handleException(TransportBroadcastOperationAction.java:263)
at org.elasticsearch.transport.netty.MessageChannelHandler.handleException(MessageChannelHandler.java:287)
at org.elasticsearch.transport.netty.MessageChannelHandler.handlerResponseError(MessageChannelHandler.java:278)
at org.elasticsearch.transport.netty.MessageChannelHandler.process(MessageChannelHandler.java:230)
at org.elasticsearch.transport.netty.MessageChannelHandler.callDecode(MessageChannelHandler.java:141)
at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:93)
at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75)
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:268)
at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:255)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:94)
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(AbstractNioWorker.java:372)
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:246)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:38)
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
2013-04-02 16:41:42,705 [New I/O worker #2] WARN transport.netty - [Jekyll] Exception caught on netty layer [[id: 0x02474fc7, /xxx.xxx.xxx.xxx:xxxx => /xxx.xxx.xxx.xxx:xxxx]] ... etc
有什么建议么?请询问您是否需要任何其他信息。
未能捕获异常的 Try/Catch 块:
def query_str = buildQuery(params)
log.debug("count query: ${query_str}");
log.debug("enter try:");
try{
def search = esclient.count {
indices "something"
types "somethingelse"
query {
query_string (query: query_str)
}
}
}
catch ( Exception e ) {
log.error("The Query is invalid!");
result.hits = 0;
}