dua*_*ty_ 5 elasticsearch elasticsearch-dsl
我正在使用Elasticsearch DSL,我想对结果进行分页.为此,我需要知道搜索结果的总数.我该怎么做才能做到最好?
我是否进行了一次搜索,然后执行两次,一次是针对.hits.total另一种针对项目进行切片?像这样的东西:
response = Link.search().filter("term", run_id=run_id)
total = response.execute().hits.total
links = response[start:end].execute()
Run Code Online (Sandbox Code Playgroud)
试试这个:
dsl = Link.search().filter("term", run_id=run_id)
response = dsl[start:end].execute()
links = response.hits.hits
total = response.hits.total
Run Code Online (Sandbox Code Playgroud)
...只能击中ElasticSearch一次.
| 归档时间: |
|
| 查看次数: |
3891 次 |
| 最近记录: |