简体   繁体   English

solr:按多值字段分组

[英]solr: group by multi valued field

I have a solr doc structure 我有一个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%
     },
    ]

I need a solr query with the response 我需要一个带有响应的solr查询

{
  headphones: 2
  mobiles: 3
  laptops: 1
  electornics: 1
}

Simply, I need the group count over a multivalues field. 简单地说,我需要对多值字段进行分组计数。

Please help me with this. 请帮我解决一下这个。

Thanks. 谢谢。

Try this: 尝试这个:

?q=*:*&facet=true&facet.field=category

make sure the multivalued field is indexed. 确保索引多值字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM