简体   繁体   中英

Spring data solr with start and rows

I know we can do paging in the Spring data solr using pageable interface.But how can get data using start and rows rather than a page?

Page<Student> findByName(String name, Pageable page)

The above function returns me the a page with the specified count. here if i set page=2 and count=10.it returns 21 to 30 items. But i require 2 to 10 items here.

So here,i don't want paging.i require start and rows same like solr. How can i do this ?

Thanks and Regards.

You can use SolrTemplate and SimpleQuery to influence start and rows .

Query query = new SimpleQuery(where("name").is(name))
  .setOffset(2)
  .setRows(8);

Page<Student> page = template.queryForPage(query, Student.class);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM