# Scroll\_id array element should only contain scroll\_id

**URL:** <https://discuss.elastic.co/t/scroll-id-array-element-should-only-contain-scroll-id/168505>\
**Category:** Elasticsearch\
**Created:** [February 15, 2019, 2:44am UTC](https://discuss.elastic.co/t/scroll-id-array-element-should-only-contain-scroll-id/168505 "2019-02-15T02:44:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamazy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iamazy/32/36501_2.png) [@iamazy](https://discuss.elastic.co/u/iamazy)\
**Post date:** [February 15, 2019, 2:44am UTC](https://discuss.elastic.co/t/scroll-id-array-element-should-only-contain-scroll-id/168505/1 "2019-02-15T02:44:40Z")

</div>

Hello  
I run this code but has exception: **type=illegal\_argument\_exception, reason=scroll\_id array element should only contain scroll\_id**

```
> public List<Map<String, Object>> testQuery(String index) throws IOException {
> 
> final Scroll scroll = new Scroll(TimeValue.timeValueMinutes(1L));
> SearchRequest searchRequest = new SearchRequest();
> searchRequest.indices(index);
> searchRequest.scroll(scroll);
> SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
> searchSourceBuilder.query(QueryBuilders.matchAllQuery());
> searchRequest.source(searchSourceBuilder);
> 
> SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
> String scrollId = searchResponse.getScrollId();
> SearchHit[] searchHits = searchResponse.getHits().getHits();
> List<Map<String, Object>> result=new ArrayList<>(0);
> while (searchHits != null && searchHits.length > 0) {
> for (SearchHit hit:searchHits){
> result.add(hit.getSourceAsMap());
> }
> SearchScrollRequest searchScrollRequest = new SearchScrollRequest(scrollId);
> searchRequest.scroll(scroll);
> searchResponse = restHighLevelClient.scroll(searchScrollRequest, RequestOptions.DEFAULT);
> scrollId = searchResponse.getScrollId();
> searchHits = searchResponse.getHits().getHits();
> }
> 
> ClearScrollRequest clearScrollRequest = new ClearScrollRequest();
> clearScrollRequest.addScrollId(scrollId);
> ClearScrollResponse clearScrollResponse = restHighLevelClient.clearScroll(clearScrollRequest, RequestOptions.DEFAULT);
> boolean succeeded = clearScrollResponse.isSucceeded();
> System.out.println(succeeded);
> return result;
> }

```

i debug this code found that the last scrollId was null,so how do i clear scroll id ?

there is full exception info:

> ```
> org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=illegal_argument_exception, reason=scroll_id array element should only contain scroll_id]
> at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177) ~[elasticsearch-6.6.0.jar:6.6.0]
> at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:2050) ~[elasticsearch-rest-high-level-client-6.6.0.jar:6.6.0]
> at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:2026) ~[elasticsearch-rest-high-level-client-6.6.0.jar:6.6.0]
> at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1775) ~[elasticsearch-rest-high-level-client-6.6.0.jar:6.6.0]
> at java.lang.Thread.run(Thread.java:748) [na:1.8.0_202]
> Suppressed: org.elasticsearch.client.ResponseException: method [DELETE], host [https://10.10.2.130:9210], URI [/_search/scroll], status line [HTTP/1.1 400 Bad Request]
> {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"scroll_id array element should only contain scroll_id"}],"type":"illegal_argument_exception","reason":"scroll_id array element should only contain scroll_id"},"status":400}
> ... 59 common frames omitted
> Caused by: org.elasticsearch.client.ResponseException: method [DELETE], host [https://10.10.2.130:9210], URI [/_search/scroll], status line [HTTP/1.1 400 Bad Request]
> {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"scroll_id array element should only contain scroll_id"}],"type":"illegal_argument_exception","reason":"scroll_id array element should only contain scroll_id"},"status":400}
> at org.elasticsearch.client.RestClient$1.completed(RestClient.java:548)
> at org.elasticsearch.client.RestClient$1.completed(RestClient.java:533)
> at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:123)
> 
> ```

---

<div class="post-metadata">

**Author:** ![Yogesh\_Gaikwad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yogesh_gaikwad/32/27025_2.png) [@Yogesh\_Gaikwad](https://discuss.elastic.co/u/Yogesh_Gaikwad)\
**Post date:** [February 15, 2019, 4:18am UTC](https://discuss.elastic.co/t/scroll-id-array-element-should-only-contain-scroll-id/168505/2 "2019-02-15T04:18:43Z")

</div>

> [@iamazy](#):
>
> SearchScrollRequest searchScrollRequest = new SearchScrollRequest(scrollId); **searchRequest.scroll(scroll);**

needs to be

> [@](#):
>
> SearchScrollRequest searchScrollRequest = new SearchScrollRequest(scrollId); **searchScrollRequest.scroll(scroll);**

Hope this helps.

---

<div class="post-metadata">

**Author:** ![iamazy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iamazy/32/36501_2.png) [@iamazy](https://discuss.elastic.co/u/iamazy)\
**Post date:** [February 15, 2019, 6:17am UTC](https://discuss.elastic.co/t/scroll-id-array-element-should-only-contain-scroll-id/168505/3 "2019-02-15T06:17:49Z")

</div>

O my G, I make a low-level mistake

Thanks a lot, Yogesh,

It solves my problem

---

<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:** [March 15, 2019, 6:17am UTC](https://discuss.elastic.co/t/scroll-id-array-element-should-only-contain-scroll-id/168505/4 "2019-03-15T06:17:51Z")

</div>

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