# Grouping of facets based on a field

**URL:** <https://discuss.elastic.co/t/grouping-of-facets-based-on-a-field/10159>\
**Category:** Elasticsearch\
**Created:** [December 21, 2012, 7:09pm UTC](https://discuss.elastic.co/t/grouping-of-facets-based-on-a-field/10159 "2012-12-21T19:09:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [December 21, 2012, 7:09pm UTC](https://discuss.elastic.co/t/grouping-of-facets-based-on-a-field/10159/1 "2012-12-21T19:09:34Z")

</div>

Hi ,

I have the following requirement

DataSet - Following are different feeds

{ "person" : "Bill Gates" , "type" : "IT guy"}  
{ "person" : "Bill Clinton" , "type" : "Politician"}  
{ "person" : "Trivolta" , "type" : "Film guy"}  
{ "person" : "Johny Depp" , "type" : "Film Guy"}  
{ "person" : "Obama" , "type" : "Politician"}  
{ "person" : "Marissa Mayor" , "type" : "IT Guy"}

Here i want the following output

"IT guy" - "Bill Gates","Marissa Mayor" , "Politician" - "Bill  
Clinton","Obama" , "Film guy" - "Johny Depp", "Trivolta"

I cant think of a way to achieve this using simple facet query.  
Running a facet in type and sending different facet query for each type is  
the only solution i could come up with.  
Kindly throw in your ideas here.

Thanks  
Vineeth

--

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [December 21, 2012, 7:40pm UTC](https://discuss.elastic.co/t/grouping-of-facets-based-on-a-field/10159/2 "2012-12-21T19:40:51Z")

</div>

Didn't you give a +1 to the field-collapsing issue a year ago? 🙂

> <https://github.com/elastic/elasticsearch/issues/256>
>
> Ability to collapse on a field. For example, I want the most relevant result fro…m all different report types. Or similarly, the most recent result of each report type. Or maybe, I want to de-dup on headline. 
> 
> So, the sort order would dictate which one from the group is returned. Similar to what is discussed here:
> http://blog.jteam.nl/2009/10/20/result-grouping-field-collapsing-with-solr/
> 
> From my understanding, it seems that in order for field collapsing to be efficient, the result set must be relatively small.
> 
> This is also referred to as "Combine" on some other search products.

I expect that grouping and field collapsing are the same issue. There is a  
non-sharded grouping implementation, but nothing distributed.

Why would you send a facet query for each type? Wouldn't the first query be  
a query faceted on type, and then a separate query (multisearch?) for each  
facet entry?

--  
Ivan

On Fri, Dec 21, 2012 at 11:09 AM, Vineeth Mohan  
[vineethmohan@algotree.com](mailto:vineethmohan@algotree.com)wrote:

> Hi ,
> 
> I have the following requirement
> 
> DataSet - Following are different feeds
> 
> { "person" : "Bill Gates" , "type" : "IT guy"}  
> { "person" : "Bill Clinton" , "type" : "Politician"}  
> { "person" : "Trivolta" , "type" : "Film guy"}  
> { "person" : "Johny Depp" , "type" : "Film Guy"}  
> { "person" : "Obama" , "type" : "Politician"}  
> { "person" : "Marissa Mayor" , "type" : "IT Guy"}
> 
> Here i want the following output
> 
> "IT guy" - "Bill Gates","Marissa Mayor" , "Politician" - "Bill  
> Clinton","Obama" , "Film guy" - "Johny Depp", "Trivolta"
> 
> I cant think of a way to achieve this using simple facet query.  
> Running a facet in type and sending different facet query for each type is  
> the only solution i could come up with.  
> Kindly throw in your ideas here.
> 
> Thanks  
> Vineeth
> 
> --

--

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [December 22, 2012, 9:39am UTC](https://discuss.elastic.co/t/grouping-of-facets-based-on-a-field/10159/3 "2012-12-22T09:39:17Z")

</div>

Hello Ivan ,

I totally forgot about that issue.  
Many thanks for reminding me.  
Multisearch was what i had in mind , thanks for pointing out that also.

Thanks  
Vineeth

On Sat, Dec 22, 2012 at 1:10 AM, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:

> Didn't you give a +1 to the field-collapsing issue a year ago? 🙂
> 
> [Field Collapsing/Combining · Issue #256 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/256)
> 
> I expect that grouping and field collapsing are the same issue. There is a  
> non-sharded grouping implementation, but nothing distributed.
> 
> Why would you send a facet query for each type? Wouldn't the first query  
> be a query faceted on type, and then a separate query (multisearch?) for  
> each facet entry?
> 
> --  
> Ivan
> 
> On Fri, Dec 21, 2012 at 11:09 AM, Vineeth Mohan \<[vineethmohan@algotree.com](mailto:vineethmohan@algotree.com)
> 
> > wrote:
> 
> > Hi ,
> > 
> > I have the following requirement
> > 
> > DataSet - Following are different feeds
> > 
> > { "person" : "Bill Gates" , "type" : "IT guy"}  
> > { "person" : "Bill Clinton" , "type" : "Politician"}  
> > { "person" : "Trivolta" , "type" : "Film guy"}  
> > { "person" : "Johny Depp" , "type" : "Film Guy"}  
> > { "person" : "Obama" , "type" : "Politician"}  
> > { "person" : "Marissa Mayor" , "type" : "IT Guy"}
> > 
> > Here i want the following output
> > 
> > "IT guy" - "Bill Gates","Marissa Mayor" , "Politician" - "Bill  
> > Clinton","Obama" , "Film guy" - "Johny Depp", "Trivolta"
> > 
> > I cant think of a way to achieve this using simple facet query.  
> > Running a facet in type and sending different facet query for each type  
> > is the only solution i could come up with.  
> > Kindly throw in your ideas here.
> > 
> > Thanks
> > 
> > ```
> > Vineeth
> > 
> > ```
> > 
> > --
> 
> --

--

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:58am UTC](https://discuss.elastic.co/t/grouping-of-facets-based-on-a-field/10159/4 "2017-07-06T02:58:40Z")

</div>

Closed on July 6, 2017, 2:58am UTC


