如何获取与给定查询匹配的文档总数。我使用了下面的查询:
result = solr.search('ad_id : 20')
print(len(result))由于默认返回值为'10',因此输出仅为10,但计数为4000。如何获取计数总数?
发布于 2017-09-24 21:16:16
results object from pysolr has a hits property that contains the total number of hits,无论返回多少个文档。这在Solr的原始响应中被命名为numFound。
您的解决方案并不真正适合具有较大数据集的任何情况,因为它要求您检索所有文档,即使您不需要它们或想要显示它们的内容。
发布于 2017-12-09 16:38:54
计数存储在numFound变量中。使用以下代码:
result = solr.search('ad_id : 20')
print(result.raw_response['response']['numFound'])发布于 2018-11-02 05:02:29
正如@MatsLindh提到的-
result = solr.search('ad_id : 20')
print(result.hits)https://stackoverflow.com/questions/46379318
复制相似问题