Solrpy how to do pagination?

时间:2017-08-04 12:37:56

标签: python solr

Solrpy is a solr client for python. The basic use is:

s = solr.SolrConnection('http://localhost:8080/solr/bt')
rows = 20
results = s.query(q, rows=rows)

How to do pagination query?

1 个答案:

答案 0 :(得分:0)

您可以使用两个参数startrows来控制分页。

示例start = 0& rows = 20将给出前20个结果,start = 20& rows = 20将给出下一组20个结果。

更新

>>> response = c.query('test', rows=20)
>>> print response.results.start
 0
>>> for match in response:
...     print match['id'],
  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
>>> response = response.next_batch()
>>> print response.results.start
 20