Scroll_id array element should only contain scroll_id


(Iamazy) #1

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)

(Yogesh Gaikwad) #2

needs to be

Hope this helps.


(Iamazy) #3

O my G, I make a low-level mistake

Thanks a lot, Yogesh,

It solves my problem


(system) closed #4

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