Hi,

If this is already answered, please point me to the thread.  TIA for that.

Now, the problem:

I am having the following code to test MultiSearchRequest{Buuilder} and it 
always throws me NullPointerException (even if I just use matchAllQuery() 
in the SearchRequests added to it).

public void performMultiSearchQuery () {
Client client = new TransportClient().addTransportAddress(new 
InetSocketTransportAddress("localhost", 9300));
SearchRequestBuilder srb1 = client.prepareSearch()
.setQuery(QueryBuilders.queryString("sev:1")).setSize(Integer.MAX_VALUE);
SearchRequestBuilder srb2 = client.prepareSearch()
.setQuery(QueryBuilders.queryString("priority:50")).setSize(Integer.MAX_VALUE);

MultiSearchResponse sr = client.prepareMultiSearch()
        .add(srb1.request())
        .add(srb2.request())
        .execute().actionGet();

// You will get all individual responses from 
MultiSearchResponse#getResponses()
long nbHits = 0;
for (MultiSearchResponse.Item item : sr.getResponses()) {
 SearchResponse response = item.getResponse();
 nbHits += response.getHits().getTotalHits();
}
 logger.info("Total Number of Hits: " + nbHits);
client.close();
}

And the exception it throws is: 

Exception in thread "main" 
org.elasticsearch.common.util.concurrent.UncategorizedExecutionException: 
Failed execution
at 
org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:90)
at 
org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:50)
at esclient.ESClient.buildQuery(ESClient.java:119)
at esclient.ESClient.main(ESClient.java:321)
Caused by: java.lang.NullPointerException
at 
org.elasticsearch.action.search.SearchRequest.writeTo(SearchRequest.java:541)
at 
org.elasticsearch.action.search.MultiSearchRequest.writeTo(MultiSearchRequest.java:271)
at 
org.elasticsearch.transport.netty.NettyTransport.sendRequest(NettyTransport.java:601)
at 
org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:206)
at 
org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:68)
at 
org.elasticsearch.client.transport.support.InternalTransportClient$2.doWithNode(InternalTransportClient.java:108)
at 
org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:219)
at 
org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:105)
at 
org.elasticsearch.client.support.AbstractClient.multiSearch(AbstractClient.java:360)
at 
org.elasticsearch.client.transport.TransportClient.multiSearch(TransportClient.java:441)
at 
org.elasticsearch.action.search.MultiSearchRequestBuilder.doExecute(MultiSearchRequestBuilder.java:78)
at 
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
at 
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)

I have searched my best and you might notice that the above code is the 
sample snippet from ES doc page.  Please help me in figuring out what the 
issue is.

P.S:- Individually both those SearchRequestBuilders are working fine.
Best,

V. Varadhan

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/badbc70d-6c2f-4f63-bb99-dec42addbfec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to