2013-04-02 66 views
0

嗨,大家好我想建立一个搜索ES的搜索引擎匹配,界面有一个动态计数器的点击,每次按键后得到更新,我正在寻找一种方法来验证,解决方法或赶上被使用,当用户搜索例如双引号抛出的异常:Netty异常未被正确捕获

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; 
} 
+0

如何向elasticsearch发送查询? – imotov

+0

添加了我使用的try/catch块。 – Mantas

回答

0

这看起来像固定在v0.19.9的错误。从v0.19.9开始,elasticsearch应该返回更合理的错误消息。

+0

我会尝试升级今天,我使用v0.19.4我会看看如何去,如果它顺利蜱是你的:)谢谢 – Mantas