# ElasticSearch Transport client is throwing exception:

**URL:** <https://discuss.elastic.co/t/elasticsearch-transport-client-is-throwing-exception/95289>\
**Category:** Elasticsearch\
**Created:** [August 1, 2017, 7:21am UTC](https://discuss.elastic.co/t/elasticsearch-transport-client-is-throwing-exception/95289 "2017-08-01T07:21:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kedarsdixit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kedarsdixit/32/20502_2.png) [@kedarsdixit](https://discuss.elastic.co/u/kedarsdixit)\
**Post date:** [August 1, 2017, 7:21am UTC](https://discuss.elastic.co/t/elasticsearch-transport-client-is-throwing-exception/95289/1 "2017-08-01T07:21:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 2, 2017, 10:43am UTC](https://discuss.elastic.co/t/elasticsearch-transport-client-is-throwing-exception/95289/2 "2017-08-02T10:43:26Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 30, 2017, 10:43am UTC](https://discuss.elastic.co/t/elasticsearch-transport-client-is-throwing-exception/95289/3 "2017-08-30T10:43:33Z")

</div>

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