我有一个solr doc结构
[
{
category:{mobiles},
name: iphone,
store: chroma,
discount: 10%
},
{
category:{mobiles,laptops},
name: Apple,
store: Reliance Digitals,
discount: 12%
},{
category:{electornics},
name: Boss,
store: chroma,
discount: 5%
},{
category:{headphones,mobiles},
name: Samsung,
store: Universal,
discount: 8%
},{
category:{headphones},
name: HTC,
store: Chroma,
discount: 50%
},
]
我需要带有响应的solr查询
{
headphones: 2
mobiles: 3
laptops: 1
electornics: 1
}
简单地说,我需要对多值字段进行分组计数。
请帮助我。
感谢。
答案 0 :(得分:3)
试试这个:
?q=*:*&facet=true&facet.field=category
确保索引多值字段。