简体   繁体   中英

solr: group by multi valued field

I have a solr doc structure

   [
     {
       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

{
  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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