Solrpy怎么分页?

2024-05-16 15:08:15 发布

您现在位置:Python中文网/ 问答频道 /正文

Solrpy是python的solr客户机。基本用途是:

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

如何进行分页查询?你知道吗


Tags: localhosthttp客户机query用途solrresultsrows
1条回答
网友
1楼 · 发布于 2024-05-16 15:08:15

您可以使用两个参数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

相关问题 更多 >