I am trying to fetch all data from elastic index with scroll id.
SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withIndices(ELASTIC_INDEX)
.withTypes(DOC_TYPE)
.withPageable(PageRequest.of(30500, BATCH_SIZE))
.withFields("id", "pid")
.build();
users = elasticsearchTemplate.startScroll(SCROLL_TIMEOUT, searchQuery, User.class);
But the pagination is not working. It always returns all the documents from page 0. There are total 30500 documents in the index, so when i set .withPageable(PageRequest.of(30500, BATCH_SIZE))
with batch size 10, there should not be any data returned, but it still returns data. What i am doing wrong here?