ParsingException in Elastic 5.0.0

Hi ,
I am trying to run very simple query using Java client

        SearchRequestBuilder searchRequestBuilder;
        String query = "{\"query\":{\"match_all\":{}}}";
        searchRequestBuilder = client.prepareSearch("test_index51");
        searchRequestBuilder.setQuery(QueryBuilders.wrapperQuery(query));
        SearchResponse response = searchRequestBuilder.execute().actionGet();

But getting below exception

Exception in thread "main" Failed to execute phase [query], all shards failed; shardFailures {[dWHd87vtQc2Nyk2-Gs4F7A][test_index51][0]: RemoteTransportException[[dWHd87v][127.0.0.1:9300][indices:data/read/search[phase/query]]]; nested: ParsingException[no [query] registered for [query]]; }{[dWHd87vtQc2Nyk2-Gs4F7A][test_index51][1]: RemoteTransportException[[dWHd87v][127.0.0.1:9300][indices:data/read/search[phase/query]]]; nested: ParsingException[no [query] registered for [query]]; }{[dWHd87vtQc2Nyk2-Gs4F7A][test_index51][2]: RemoteTransportException[[dWHd87v][127.0.0.1:9300][indices:data/read/search[phase/query]]]; nested: ParsingException[no [query] registered for [query]]; }{[dWHd87vtQc2Nyk2-Gs4F7A][test_index51][3]: RemoteTransportException[[dWHd87v][127.0.0.1:9300][indices:data/read/search[phase/query]]]; nested: ParsingException[no [query] registered for [query]]; }{[dWHd87vtQc2Nyk2-Gs4F7A][test_index51][4]: RemoteTransportException[[dWHd87v][127.0.0.1:9300][indices:data/read/search[phase/query]]]; nested: ParsingException[no [query] registered for [query]]; }
	at org.elasticsearch.action.search.AbstractSearchAsyncAction.onFirstPhaseResult(AbstractSearchAsyncAction.java:235)
	at org.elasticsearch.action.search.AbstractSearchAsyncAction$1.onFailure(AbstractSearchAsyncAction.java:170)
	at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:51)
	at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:954)
	at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1055)
	at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1033)
	at org.elasticsearch.transport.TransportService$6.onFailure(TransportService.java:559)
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.onFailure(ThreadContext.java:490)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:39)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

but same query works through curl. How can I pass a query string in search request?

I believe it is more like:

        SearchRequestBuilder searchRequestBuilder;
        String query = "{\"match_all\":{}}";
        searchRequestBuilder = client.prepareSearch("test_index51");
        searchRequestBuilder.setQuery(QueryBuilders.wrapperQuery(query));
        SearchResponse response = searchRequestBuilder.execute().actionGet();

This is how it is tested.

1 Like