我有一个用小型“缓存”和 Spring Data Solr 编写的解决方案。在这种情况下,仅在需要时才传递请求。您可以根据自己的目的扩展或更改它。
SolrLazyQuery (Pagination) mit Vaadin Grid 和 Spring Data Solr
final LazyPagedContainer<T> container = new LazyPagedContainer<>(this.currentGenericClass);
container.setLazyQuery(new LazyContainerQuery<T>(firstPage) {
@Override
protected Page<T> getPageByNumber(final int pageNumber) {
final SolrPageRequest solrPage = new SolrPageRequest(pageNumber, PAGE_SIZE, MyGrid.this.currentSort);
return MyGrid.this.search(solrPage, MyGrid.this.currentSearch, MyGrid.this.currentFilterValues);
}
});
Vaadin Grid / Table requests to this query:
startIndex: 0, numberOfIds: 95
startIndex: 0, numberOfIds: 139
startIndex: 52, numberOfIds: 171
startIndex: 137, numberOfIds: 171
[...]
Requests to Solr:
start: 0 rows: 100
start: 100 rows: 100
start: 200 rows: 100
start: 300 rows: 100
[...]