我正在使用此 url 查询 Solr 核心:
select?q=*:*&rows=0&facet=on&facet.limit=-1&facet.mincount=0&facet.pivot=brand,series,sub_series
使用Facet Pivot功能
部分 JSON 响应,注意字段是如何正确嵌套的:
"facet_pivot":{
"brand,series,sub_series":[{
"field":"brand",
"value":"A. Lange & Sohne",
"count":69,
"pivot":[{
"field":"series",
"value":"1815 Manual Wind",
"count":1},
{
"field":"series",
"value":"1815 Up Down",
"count":1},
{
"field":"series",
"value":"Datograph",
"count":3,
"pivot":[{
"field":"sub_series",
"value":"Perpetual",
"count":2},
{
"field":"sub_series",
"value":"Up Down",
"count":1}]},
现在我用 pySolr 复制相同的查询:
def nested_navbar():
result = solr.search('*:*', **{
'rows': '0',
'facet': 'on',
'facet.limit': '-1',
'facet.mincount': '0',
'facet.pivot': ['brand_exact', 'series_exact', 'sub_series_exact']
})
result = result.facets['facet_pivot']
return result
出于某种原因,当我打印数据(pdb 或 Django 模板)时,结果中的字典有 3 个不同的品牌数组、系列和子系列,没有原始嵌套。换句话说,pivot 字段消失了。