2013-04-02 88 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