2
votes

I'm trying to retrieve pageable information from elasticsearch 5.4.0 using current spring-boot-starter-data-elasticsearch 2.0.0.BUILD-SNAPSHOT that uses spring-data-elasticsearch 3.0.0.BUILD-SNAPSHOT, but it doesn't work as expected.

Page<Customer> page = this.repository.findByLastName("Smith", PageRequest.of(0, 1));

System.out.println("page = " + page);
System.out.println("page.getSize() = " + page.getSize());
System.out.println("page.getTotalPages() = " + page.getTotalPages());
System.out.println("page.getTotalElements() = " + page.getTotalElements());
System.out.println("page.getNumber() = " + page.getNumber());
System.out.println("page.getNumberOfElements() = " + page.getNumberOfElements());
System.out.println("page.nextPageable().isUnpaged() = " + page.nextPageable().isUnpaged());
System.out.println("page.getContent() = " + page.getContent());

This code returns:

page = Page 1 of 1 containing sample.data.elasticsearch.Customer instances
page.getSize() = 0
page.getTotalPages() = 1
page.getTotalElements() = 4
page.getNumber() = 0
page.getNumberOfElements() = 1
page.nextPageable().isUnpaged() = true
page.getContent() = [Customer[id=AV304Kn3zw7_0HN9017l, firstName='Alice', lastName='Smith']]

Even if there are 4 total elements, there is only one page, and size is 0. I've tried it with older stable versions of spring-data-elasticsearch and elastic-search 1.x and 2.x and it worked good.

For the purpose of example I've modified the sample project from official spring-boot repository. (https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-data-elasticsearch)

1

1 Answers

0
votes

Seems you've same problem as us. I found an explanation on Spring Data Elasticsearch Jira DATAES-402. Unfortunately, in release 3.0.2, the bug persists.