ElasticSearch Transport client is throwing exception:


(Kedar Dixit) #1

Hi,

I am using ES transport client for pulling data using scroll, I am using ES 5.5.

When I run the code I am getting below mentioned exception:

Exception in thread "main" org.elasticsearch.action.ActionRequestValidationException: Validation Failed: 1: scrollId is missing;
	at org.elasticsearch.action.ValidateActions.addValidationError(ValidateActions.java:29)
	at org.elasticsearch.action.search.SearchScrollRequest.validate(SearchScrollRequest.java:55)
	at org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:46)
	at org.elasticsearch.client.transport.TransportProxyClient.lambda$execute$0(TransportProxyClient.java:59)
	at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:251)
	at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)
	at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:366)
	at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408)
	at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80)
	at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54)

My Code Snippet:

TransportClient client = new PreBuiltTransportClient(settings).addTransportAddress(new InetSocketTransportAddress(
                InetAddress.getByName("hostname"), 9001));
      
        for (String searchIndex : conf.getIndexes()) {
            SearchResponse response = client.prepareSearch(searchIndex + "*")
                .addSort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC)
                .setScroll(new TimeValue(6000))
                .setSize(100).get();

            // max of 100 hits will be returned for each scroll
            // Scroll until no hits are returned
            do {
                for (SearchHit searchHit : response.getHits().getHits()) {
                    // Handle the hit...
                    String data = printResponse(searchHit.getSource());
                    if (data.length() > 0) {
                       
                            writeDataToFile(data);
                    }
                }
                response = client
                    .prepareSearchScroll(response.getScrollId())
                    .setScroll(new TimeValue(6000))
                    .execute().actionGet();
            } while (response.getHits().getHits().length != 0);
        }

Can some one help ?

Thanks,
~Kedar


(David Pilato) #2

I'm just wondering if you should replace the do { } while () block with a while () { } block.

In case the first search response does not bring back any hit...


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.