【发布时间】:2012-05-25 15:45:59
【问题描述】:
如何在 Solr 中对 facet 计数进行分页?我知道我有 facet.offset 来跳过记录,但我怎么知道有多少条记录有 facet?
【问题讨论】:
-
facet.query表示“有多少条记录有这个方面”?
标签: solr count pagination facet
如何在 Solr 中对 facet 计数进行分页?我知道我有 facet.offset 来跳过记录,但我怎么知道有多少条记录有 facet?
【问题讨论】:
facet.query 表示“有多少条记录有这个方面”?
标签: solr count pagination facet
您需要应用 Solr Patch SOLR-2242 以获取 Facet 不同计数。
总计数有助于分页。
【讨论】:
在 Solr 5.3 及以上版本中使用 facet 获取文档总数,
为了那个简单的使用,
facet=on
例如
http://<solr-url>/select?facet=on&indent=on&q=*:*&rows=0&wt=json
然后你会得到一个 facets 对象作为响应,它看起来像,
{
"responseHeader":{
"zkConnected":true,
"status":0,
"QTime":3,
"params":{
"q":"*:*",
"indent":"on",
"rows":"0",
"facet":"on",
"wt":"json"}},
"response":{"numFound":8,"start":0,"maxScore":1.0,"docs":[]
},
"facet_counts":{
"facet_queries":{},
"facet_fields":{},
"facet_ranges":{},
"facet_intervals":{},
"facet_heatmaps":{}}
}
你从response得到numFound,这是那个solr核心中的记录总数
另一种方式
如果您有任何方面查询,请使用,
facet=on&json.facet={}
例如
http://<solr-url>/select?facet=on&indent=on&json.facet={}&q=*:*&rows=0&wt=json
然后你会得到一个 facets 对象作为响应,它看起来像,
{
"responseHeader":{
"zkConnected":true,
"status":0,
"QTime":3,
"params":{
"json.facet":"{}",
"q":"*:*",
"indent":"on",
"rows":"0",
"facet":"on",
"wt":"json"}},
"response":{"numFound":80,"start":0,"maxScore":1.0,"docs":[]
},
"facet_counts":{
"facet_queries":{},
"facet_fields":{},
"facet_ranges":{},
"facet_intervals":{},
"facet_heatmaps":{}},
"facets":{
"count":80}}
从facets对象你得到count,这是最大记录数
【讨论】: