0
{ 
   'companyName' : 'xyz',
   'title'       : 'xyz acquired companyB',
   'source'      : 'google.com'
},
{ 
   'companyName' : 'xyz',
   'title'       : 'xyz acquired companyB'
   'source'      : 'bing.com'
}

Above is the structure of my SOLR document.

The requirement which I have is, I have to group the document by 'companyName' and fetch only unique results of 'title'.

The result has to be something like this

 "groups":[{
    "groupValue":"xyz",
    "doclist":{"numFound":1,"start":0,"docs":[
        {
            'companyName' : 'xyz',
            'title'       : 'xyz acquired companyB',
            'source'      : 'google.com'
        }
     ]
   }
 ]

I tried what is specified in here. But I'm unable to achieve the requirement.

Community
  • 1
  • 1
Edi
  • 327
  • 4
  • 16

1 Answers1

0

Use Result Grouping - which is a variant of faceting.

&group=true&group.field=companyName

This seems to match the output you're suggesting.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84