Error while using Java API for Search on query


(Ravi Dontharaju) #1

Hi,
I am using Elasticsearch 0.18.2. I am trying to connect to port 9300 on localhost.

  • I am able to create documents and get documents by _id on elasticsearch using Java API.
    GetResponse response =
    elasticSearchClient
    .prepareGet()
    .setIndex(index)
    .setType(type)
    .setId(id)
    .execute()
    .actionGet();

  • I am able to search using curl/json and I get a valid response and hits.
    curl -XPOST 'http://localhost:9200/test/product_data/_search?pretty=ok' -d '{
    "query" : {"term" : {"brand" : "toshiba"} }}'

But when I am trying to search using Java API using the following code:
QueryBuilder qb1 = termQuery("brand", "toshiba");
SearchResponse searchResponse = elasticSearchClient.prepareSearch("test")
.setTypes("product_data")
.setSearchType(SearchType.DEFAULT)
.setQuery(qb1)
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();

I get the following error:

2011-11-15 13:34:49,958 [New I/O client worker #1-5] WARN org.elasticsearch.transport.netty - [Braddock, Elizabeth "Betsy"] Exception caught on netty layer [[id: 0x1cad7d80, /127.0.0.1:57576 => localhost/127.0.0.1:9300]]
java.lang.NoSuchMethodError: org.apache.lucene.analysis.standard.StandardAnalyzer.(Lorg/apache/lucene/util/Version;)V
at org.elasticsearch.common.lucene.Lucene.(Lucene.java:56)
at org.elasticsearch.search.internal.InternalSearchHit.readFrom(InternalSearchHit.java:422)
at org.elasticsearch.search.internal.InternalSearchHit.readSearchHit(InternalSearchHit.java:403)
at org.elasticsearch.search.internal.InternalSearchHits.readFrom(InternalSearchHits.java:211)
at org.elasticsearch.search.internal.InternalSearchHits.readFrom(InternalSearchHits.java:191)
at org.elasticsearch.search.internal.InternalSearchHits.readSearchHits(InternalSearchHits.java:186)
at org.elasticsearch.search.internal.InternalSearchResponse.readFrom(InternalSearchResponse.java:84)
at org.elasticsearch.search.internal.InternalSearchResponse.readInternalSearchResponse(InternalSearchResponse.java:79)
at org.elasticsearch.action.search.SearchResponse.readFrom(SearchResponse.java:284)
at org.elasticsearch.transport.netty.MessageChannelHandler.handleResponse(MessageChannelHandler.java:132)
at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:111)
at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80)
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:783)
at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:302)
at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:317)
at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:299)
at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:216)
at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80)
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:274)
at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:261)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:349)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:280)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:200)
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:44)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Confused as hell, can anyone help?
-Ravi


(system) #2