# Can I group facet counts?

**URL:** <https://discuss.elastic.co/t/can-i-group-facet-counts/13887>\
**Category:** Elasticsearch\
**Created:** [October 9, 2013, 2:57pm UTC](https://discuss.elastic.co/t/can-i-group-facet-counts/13887 "2013-10-09T14:57:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [October 9, 2013, 2:57pm UTC](https://discuss.elastic.co/t/can-i-group-facet-counts/13887/1 "2013-10-09T14:57:23Z")

</div>

Is there a way to group a facet count based on another property. For  
example, if my data looks like this:

{  
"book":{  
"id": "1234",  
"pages":[  
{  
"title": "elastic",  
"images" : [  
{  
"name" : "some image",  
"mimeType": "image/png",  
},  
{  
"name" : "another image",  
"mimeType": "image/png",  
}  
]  
}  
]  
}  
}

and in my model I have made "pages" and "images" nested types.

I want to be able to facet on the 'mimeType' property of the images within  
the pages of the book (i.e. book.pages.images.mimeType), but for my example  
data above this will show a facet count of 2 for the 'image/png' mime type.  
Is there any way to group these two facets based on another property, i.e.  
book.id so that 'image/png' facet will only show only show a count of 1?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 9, 2013, 3:34pm UTC](https://discuss.elastic.co/t/can-i-group-facet-counts/13887/2 "2013-10-09T15:34:03Z")

</div>

Hey,

you could use the terms facet in combination with a script which  
concatenates the fields together to create a unique. Obviously a bit slower  
than doing this on indexing time, but maybe sufficient in your case...

Hope this helps.

--Alex

On Wed, Oct 9, 2013 at 4:57 PM, dan [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> Is there a way to group a facet count based on another property. For  
> example, if my data looks like this:
> 
> {  
> "book":{  
> "id": "1234",  
> "pages":[  
> {  
> "title": "elastic",  
> "images" : [  
> {  
> "name" : "some image",  
> "mimeType": "image/png",  
> },  
> {  
> "name" : "another image",  
> "mimeType": "image/png",  
> }  
> ]  
> }  
> ]  
> }  
> }
> 
> and in my model I have made "pages" and "images" nested types.
> 
> I want to be able to facet on the 'mimeType' property of the images within  
> the pages of the book (i.e. book.pages.images.mimeType), but for my example  
> data above this will show a facet count of 2 for the 'image/png' mime type.  
> Is there any way to group these two facets based on another property, i.e.  
> book.id so that 'image/png' facet will only show only show a count of 1?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [October 9, 2013, 4:05pm UTC](https://discuss.elastic.co/t/can-i-group-facet-counts/13887/3 "2013-10-09T16:05:17Z")

</div>

Thanks Alex, could I use this with range facets too. Are there any examples  
anywhere?

On Wednesday, October 9, 2013 4:34:03 PM UTC+1, Alexander Reelsen wrote:

> Hey,
> 
> you could use the terms facet in combination with a script which  
> concatenates the fields together to create a unique. Obviously a bit slower  
> than doing this on indexing time, but maybe sufficient in your case...
> 
> Hope this helps.
> 
> --Alex
> 
> On Wed, Oct 9, 2013 at 4:57 PM, dan \<[dan.t...@gmail.com](mailto:dan.t...@gmail.com) \<javascript:\>\>wrote:
> 
> > Is there a way to group a facet count based on another property. For  
> > example, if my data looks like this:
> > 
> > {  
> > "book":{  
> > "id": "1234",  
> > "pages":[  
> > {  
> > "title": "elastic",  
> > "images" : [  
> > {  
> > "name" : "some image",  
> > "mimeType": "image/png",  
> > },  
> > {  
> > "name" : "another image",  
> > "mimeType": "image/png",  
> > }  
> > ]  
> > }  
> > ]  
> > }  
> > }
> > 
> > and in my model I have made "pages" and "images" nested types.
> > 
> > I want to be able to facet on the 'mimeType' property of the images  
> > within the pages of the book (i.e. book.pages.images.mimeType), but for my  
> > example data above this will show a facet count of 2 for the 'image/png'  
> > mime type. Is there any way to group these two facets based on another  
> > property, i.e. book.id so that 'image/png' facet will only show only  
> > show a count of 1?
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 10, 2013, 7:10am UTC](https://discuss.elastic.co/t/can-i-group-facet-counts/13887/4 "2013-10-10T07:10:44Z")

</div>

Hey,

range facets also support key\_script and value\_script parameters. There is  
a simple example for the terms facet at

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Regarding key\_script and value\_script. It uses the key part for bucketing  
and the value for the range statistics. Take this (artificial) example

"posts\_tagging": {  
"range" : {  
"key\_script" : "doc['release\_date'].date.year",  
"value\_script" : "doc['tags'].size()",  
"ranges" : [  
{ "to" : 1970 },  
{ "from" : 1970, "to" : 1990 },  
{ "from" : 1990 }  
]  
}  
}

You could actually get statistics if the posts which have a tags array and  
a release date were more heavily tagged since 1990 onwards compared to  
earlier days.

Hope this helps...

--Alex

On Wed, Oct 9, 2013 at 6:05 PM, dan [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> Thanks Alex, could I use this with range facets too. Are there any  
> examples anywhere?
> 
> On Wednesday, October 9, 2013 4:34:03 PM UTC+1, Alexander Reelsen wrote:
> 
> > Hey,
> > 
> > you could use the terms facet in combination with a script which  
> > concatenates the fields together to create a unique. Obviously a bit slower  
> > than doing this on indexing time, but maybe sufficient in your case...
> > 
> > Hope this helps.
> > 
> > --Alex
> > 
> > On Wed, Oct 9, 2013 at 4:57 PM, dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > 
> > > Is there a way to group a facet count based on another property. For  
> > > example, if my data looks like this:
> > > 
> > > {  
> > > "book":{  
> > > "id": "1234",  
> > > "pages":[  
> > > {  
> > > "title": "elastic",  
> > > "images" : [  
> > > {  
> > > "name" : "some image",  
> > > "mimeType": "image/png",  
> > > },  
> > > {  
> > > "name" : "another image",  
> > > "mimeType": "image/png",  
> > > }  
> > > ]  
> > > }  
> > > ]  
> > > }  
> > > }
> > > 
> > > and in my model I have made "pages" and "images" nested types.
> > > 
> > > I want to be able to facet on the 'mimeType' property of the images  
> > > within the pages of the book (i.e. book.pages.images.mimeType), but for my  
> > > example data above this will show a facet count of 2 for the 'image/png'  
> > > mime type. Is there any way to group these two facets based on another  
> > > property, i.e. book.id so that 'image/png' facet will only show only  
> > > show a count of 1?
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [October 10, 2013, 3:28pm UTC](https://discuss.elastic.co/t/can-i-group-facet-counts/13887/5 "2013-10-10T15:28:18Z")

</div>

Say I wanted to do a range facet on the image "size" property and group the  
facets by book "id"  
{  
"book":{  
"id": "1234",  
"pages":[  
{  
"title": "elastic",  
"images" : [  
{  
"name" : "some image",  
"mimeType": "image/png",  
"size", 100  
},  
{  
"name" : "another image",  
"mimeType": "image/png",  
"size", 100  
}  
]  
}  
]  
}  
}

I have been trying this query

{  
"from" : 0,  
"size" : 1,  
"query" : {  
"query\_string" : {  
"query" : "_:_"  
}  
},  
"explain" : true,  
"facets" : {  
"contentSize" : {  
"range" : {  
"key\_script" : "doc['size']",  
"value\_script": "doc['id']",  
"ranges" : [ {  
"from" : 0.0,  
"to" : 1048576.0  
} ]  
}  
}  
}  
}

I don't think I clearly understand the 'value\_script' property. I am  
getting back the following exception,

Query Failed [Failed to execute main query]]; nested:  
ClassCastException[org.elasticsearch.index.fielddata.ScriptDocValues$NumericLong  
cannot be cast to java.lang.Number]; }

On Thursday, October 10, 2013 8:10:44 AM UTC+1, Alexander Reelsen wrote:

> Hey,
> 
> range facets also support key\_script and value\_script parameters. There is  
> a simple example for the terms facet at  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-facet.html)
> 
> Regarding key\_script and value\_script. It uses the key part for bucketing  
> and the value for the range statistics. Take this (artificial) example
> 
> "posts\_tagging": {  
> "range" : {  
> "key\_script" : "doc['release\_date'].date.year",  
> "value\_script" : "doc['tags'].size()",  
> "ranges" : [  
> { "to" : 1970 },  
> { "from" : 1970, "to" : 1990 },  
> { "from" : 1990 }  
> ]  
> }  
> }
> 
> You could actually get statistics if the posts which have a tags array and  
> a release date were more heavily tagged since 1990 onwards compared to  
> earlier days.
> 
> Hope this helps...
> 
> --Alex
> 
> On Wed, Oct 9, 2013 at 6:05 PM, dan \<[dan.t...@gmail.com](mailto:dan.t...@gmail.com) \<javascript:\>\>wrote:
> 
> > Thanks Alex, could I use this with range facets too. Are there any  
> > examples anywhere?
> > 
> > On Wednesday, October 9, 2013 4:34:03 PM UTC+1, Alexander Reelsen wrote:
> > 
> > > Hey,
> > > 
> > > you could use the terms facet in combination with a script which  
> > > concatenates the fields together to create a unique. Obviously a bit slower  
> > > than doing this on indexing time, but maybe sufficient in your case...
> > > 
> > > Hope this helps.
> > > 
> > > --Alex
> > > 
> > > On Wed, Oct 9, 2013 at 4:57 PM, dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > 
> > > > Is there a way to group a facet count based on another property. For  
> > > > example, if my data looks like this:
> > > > 
> > > > {  
> > > > "book":{  
> > > > "id": "1234",  
> > > > "pages":[  
> > > > {  
> > > > "title": "elastic",  
> > > > "images" : [  
> > > > {  
> > > > "name" : "some image",  
> > > > "mimeType": "image/png",  
> > > > },  
> > > > {  
> > > > "name" : "another image",  
> > > > "mimeType": "image/png",  
> > > > }  
> > > > ]  
> > > > }  
> > > > ]  
> > > > }  
> > > > }
> > > > 
> > > > and in my model I have made "pages" and "images" nested types.
> > > > 
> > > > I want to be able to facet on the 'mimeType' property of the images  
> > > > within the pages of the book (i.e. book.pages.images.mimeType), but for my  
> > > > example data above this will show a facet count of 2 for the 'image/png'  
> > > > mime type. Is there any way to group these two facets based on another  
> > > > property, i.e. book.id so that 'image/png' facet will only show only  
> > > > show a count of 1?
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > > 
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send an  
> > > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 10, 2013, 3:49pm UTC](https://discuss.elastic.co/t/can-i-group-facet-counts/13887/6 "2013-10-10T15:49:17Z")

</div>

Hey,

use doc['size'].value and doc['id'].value instead and see if it works.

--Alex

On Thu, Oct 10, 2013 at 5:28 PM, dan [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> Say I wanted to do a range facet on the image "size" property and group  
> the facets by book "id"
> 
> {  
> "book":{  
> "id": "1234",  
> "pages":[  
> {  
> "title": "elastic",  
> "images" : [  
> {  
> "name" : "some image",  
> "mimeType": "image/png",  
> "size", 100
> 
> ```
> },
> {
> "name" : "another image",
> "mimeType": "image/png",
> "size", 100
> }
> ]
> }
> ]
> 
> ```
> 
> }  
> }
> 
> I have been trying this query
> 
> {  
> "from" : 0,  
> "size" : 1,  
> "query" : {  
> "query\_string" : {  
> "query" : "_:_"  
> }  
> },  
> "explain" : true,  
> "facets" : {  
> "contentSize" : {  
> "range" : {  
> "key\_script" : "doc['size']",  
> "value\_script": "doc['id']",  
> "ranges" : [ {  
> "from" : 0.0,  
> "to" : 1048576.0  
> } ]  
> }  
> }  
> }  
> }
> 
> I don't think I clearly understand the 'value\_script' property. I am  
> getting back the following exception,
> 
> Query Failed [Failed to execute main query]]; nested:  
> ClassCastException[org.elasticsearch.index.fielddata.ScriptDocValues$NumericLong  
> cannot be cast to java.lang.Number]; }
> 
> On Thursday, October 10, 2013 8:10:44 AM UTC+1, Alexander Reelsen wrote:
> 
> > Hey,
> > 
> > range facets also support key\_script and value\_script parameters. There  
> > is a simple example for the terms facet at [http://www.elasticsearch](http://www.elasticsearch).\*\*  
> > org/guide/en/elasticsearch/ **reference/current/search-**  
> > facets-terms-facet.html[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-facet.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-facet.html)
> > 
> > Regarding key\_script and value\_script. It uses the key part for bucketing  
> > and the value for the range statistics. Take this (artificial) example
> > 
> > "posts\_tagging": {  
> > "range" : {  
> > "key\_script" : "doc['release\_date'].date.\*\*year",  
> > "value\_script" : "doc['tags'].size()",  
> > "ranges" : [  
> > { "to" : 1970 },  
> > { "from" : 1970, "to" : 1990 },  
> > { "from" : 1990 }  
> > ]  
> > }  
> > }
> > 
> > You could actually get statistics if the posts which have a tags array  
> > and a release date were more heavily tagged since 1990 onwards compared to  
> > earlier days.
> > 
> > Hope this helps...
> > 
> > --Alex
> > 
> > On Wed, Oct 9, 2013 at 6:05 PM, dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > 
> > > Thanks Alex, could I use this with range facets too. Are there any  
> > > examples anywhere?
> > > 
> > > On Wednesday, October 9, 2013 4:34:03 PM UTC+1, Alexander Reelsen wrote:
> > > 
> > > > Hey,
> > > > 
> > > > you could use the terms facet in combination with a script which  
> > > > concatenates the fields together to create a unique. Obviously a bit slower  
> > > > than doing this on indexing time, but maybe sufficient in your case...
> > > > 
> > > > Hope this helps.
> > > > 
> > > > --Alex
> > > > 
> > > > On Wed, Oct 9, 2013 at 4:57 PM, dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > 
> > > > > Is there a way to group a facet count based on another property. For  
> > > > > example, if my data looks like this:
> > > > > 
> > > > > {  
> > > > > "book":{  
> > > > > "id": "1234",  
> > > > > "pages":[  
> > > > > {  
> > > > > "title": "elastic",  
> > > > > "images" : [  
> > > > > {  
> > > > > "name" : "some image",  
> > > > > "mimeType": "image/png",  
> > > > > },  
> > > > > {  
> > > > > "name" : "another image",  
> > > > > "mimeType": "image/png",  
> > > > > }  
> > > > > ]  
> > > > > }  
> > > > > ]  
> > > > > }  
> > > > > }
> > > > > 
> > > > > and in my model I have made "pages" and "images" nested types.
> > > > > 
> > > > > I want to be able to facet on the 'mimeType' property of the images  
> > > > > within the pages of the book (i.e. book.pages.images.mimeType), but for my  
> > > > > example data above this will show a facet count of 2 for the 'image/png'  
> > > > > mime type. Is there any way to group these two facets based on another  
> > > > > property, i.e. book.id so that 'image/png' facet will only show only  
> > > > > show a count of 1?
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to the Google  
> > > > > Groups "elasticsearch" group.  
> > > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > > an email to elasticsearc...@\*\*googlegroups.\*\*com.
> > > > > 
> > > > > For more options, visit [https://groups.google.com/\*\*grou\*\*ps/opt\_out](https://groups.google.com/ **grou** ps/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > .
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).  
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [October 10, 2013, 3:55pm UTC](https://discuss.elastic.co/t/can-i-group-facet-counts/13887/7 "2013-10-10T15:55:09Z")

</div>

Slightly different exception:

nested: ClassCastException[java.lang.String cannot be cast to  
java.lang.Number]

On Thursday, October 10, 2013 4:49:17 PM UTC+1, Alexander Reelsen wrote:

> Hey,
> 
> use doc['size'].value and doc['id'].value instead and see if it works.
> 
> --Alex
> 
> On Thu, Oct 10, 2013 at 5:28 PM, dan \<[dan.t...@gmail.com](mailto:dan.t...@gmail.com) \<javascript:\>\>wrote:
> 
> > Say I wanted to do a range facet on the image "size" property and group  
> > the facets by book "id"
> > 
> > {  
> > "book":{  
> > "id": "1234",  
> > "pages":[  
> > {  
> > "title": "elastic",  
> > "images" : [  
> > {  
> > "name" : "some image",  
> > "mimeType": "image/png",  
> > "size", 100
> > 
> > ```
> > },
> > {
> > "name" : "another image",
> > "mimeType": "image/png",
> > "size", 100
> > }
> > ]
> > }
> > ]
> > 
> > ```
> > 
> > }  
> > }
> > 
> > I have been trying this query
> > 
> > {  
> > "from" : 0,  
> > "size" : 1,  
> > "query" : {  
> > "query\_string" : {  
> > "query" : "_:_"  
> > }  
> > },  
> > "explain" : true,  
> > "facets" : {  
> > "contentSize" : {  
> > "range" : {  
> > "key\_script" : "doc['size']",  
> > "value\_script": "doc['id']",  
> > "ranges" : [ {  
> > "from" : 0.0,  
> > "to" : 1048576.0  
> > } ]  
> > }  
> > }  
> > }  
> > }
> > 
> > I don't think I clearly understand the 'value\_script' property. I am  
> > getting back the following exception,
> > 
> > Query Failed [Failed to execute main query]]; nested:  
> > ClassCastException[org.elasticsearch.index.fielddata.ScriptDocValues$NumericLong  
> > cannot be cast to java.lang.Number]; }
> > 
> > On Thursday, October 10, 2013 8:10:44 AM UTC+1, Alexander Reelsen wrote:
> > 
> > > Hey,
> > > 
> > > range facets also support key\_script and value\_script parameters. There  
> > > is a simple example for the terms facet at [http://www.elasticsearch](http://www.elasticsearch).\*\*  
> > > org/guide/en/elasticsearch/ **reference/current/search-**  
> > > facets-terms-facet.html[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-facet.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-facet.html)
> > > 
> > > Regarding key\_script and value\_script. It uses the key part for  
> > > bucketing and the value for the range statistics. Take this (artificial)  
> > > example
> > > 
> > > "posts\_tagging": {  
> > > "range" : {  
> > > "key\_script" : "doc['release\_date'].date.\*\*year",  
> > > "value\_script" : "doc['tags'].size()",  
> > > "ranges" : [  
> > > { "to" : 1970 },  
> > > { "from" : 1970, "to" : 1990 },  
> > > { "from" : 1990 }  
> > > ]  
> > > }  
> > > }
> > > 
> > > You could actually get statistics if the posts which have a tags array  
> > > and a release date were more heavily tagged since 1990 onwards compared to  
> > > earlier days.
> > > 
> > > Hope this helps...
> > > 
> > > --Alex
> > > 
> > > On Wed, Oct 9, 2013 at 6:05 PM, dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > 
> > > > Thanks Alex, could I use this with range facets too. Are there any  
> > > > examples anywhere?
> > > > 
> > > > On Wednesday, October 9, 2013 4:34:03 PM UTC+1, Alexander Reelsen wrote:
> > > > 
> > > > > Hey,
> > > > > 
> > > > > you could use the terms facet in combination with a script which  
> > > > > concatenates the fields together to create a unique. Obviously a bit slower  
> > > > > than doing this on indexing time, but maybe sufficient in your case...
> > > > > 
> > > > > Hope this helps.
> > > > > 
> > > > > --Alex
> > > > > 
> > > > > On Wed, Oct 9, 2013 at 4:57 PM, dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > > 
> > > > > > Is there a way to group a facet count based on another property. For  
> > > > > > example, if my data looks like this:
> > > > > > 
> > > > > > {  
> > > > > > "book":{  
> > > > > > "id": "1234",  
> > > > > > "pages":[  
> > > > > > {  
> > > > > > "title": "elastic",  
> > > > > > "images" : [  
> > > > > > {  
> > > > > > "name" : "some image",  
> > > > > > "mimeType": "image/png",  
> > > > > > },  
> > > > > > {  
> > > > > > "name" : "another image",  
> > > > > > "mimeType": "image/png",  
> > > > > > }  
> > > > > > ]  
> > > > > > }  
> > > > > > ]  
> > > > > > }  
> > > > > > }
> > > > > > 
> > > > > > and in my model I have made "pages" and "images" nested types.
> > > > > > 
> > > > > > I want to be able to facet on the 'mimeType' property of the images  
> > > > > > within the pages of the book (i.e. book.pages.images.mimeType), but for my  
> > > > > > example data above this will show a facet count of 2 for the 'image/png'  
> > > > > > mime type. Is there any way to group these two facets based on another  
> > > > > > property, i.e. book.id so that 'image/png' facet will only show only  
> > > > > > show a count of 1?
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to the Google  
> > > > > > Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > send an email to elasticsearc...@\*\*googlegroups.\*\*com.
> > > > > > 
> > > > > > For more options, visit [https://groups.google.com/\*\*grou\*\*ps/opt\_out](https://groups.google.com/ **grou** ps/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > > .
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to the Google  
> > > > > Groups "elasticsearch" group.  
> > > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).  
> > > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > .
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send an  
> > > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 11, 2013, 6:28am UTC](https://discuss.elastic.co/t/can-i-group-facet-counts/13887/8 "2013-10-11T06:28:54Z")

</div>

Hey,

is your data of the field maybe stored as a string instead of a number in  
the mapping? (Use the GET Mapping API to find out)...

--Alex

On Thu, Oct 10, 2013 at 5:55 PM, dan [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> Slightly different exception:
> 
> nested: ClassCastException[java.lang.String cannot be cast to  
> java.lang.Number]
> 
> On Thursday, October 10, 2013 4:49:17 PM UTC+1, Alexander Reelsen wrote:
> 
> > Hey,
> > 
> > use doc['size'].value and doc['id'].value instead and see if it works.
> > 
> > --Alex
> > 
> > On Thu, Oct 10, 2013 at 5:28 PM, dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > 
> > > Say I wanted to do a range facet on the image "size" property and group  
> > > the facets by book "id"
> > > 
> > > {  
> > > "book":{  
> > > "id": "1234",  
> > > "pages":[  
> > > {  
> > > "title": "elastic",  
> > > "images" : [  
> > > {  
> > > "name" : "some image",  
> > > "mimeType": "image/png",  
> > > "size", 100
> > > 
> > > ```
> > > },
> > > {
> > > "name" : "another image",
> > > "mimeType": "image/png",
> > > "size", 100
> > > }
> > > ]
> > > }
> > > ]
> > > 
> > > ```
> > > 
> > > }  
> > > }
> > > 
> > > I have been trying this query
> > > 
> > > {  
> > > "from" : 0,  
> > > "size" : 1,  
> > > "query" : {  
> > > "query\_string" : {  
> > > "query" : "_:_"  
> > > }  
> > > },  
> > > "explain" : true,  
> > > "facets" : {  
> > > "contentSize" : {  
> > > "range" : {  
> > > "key\_script" : "doc['size']",  
> > > "value\_script": "doc['id']",  
> > > "ranges" : [ {  
> > > "from" : 0.0,  
> > > "to" : 1048576.0  
> > > } ]  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > I don't think I clearly understand the 'value\_script' property. I am  
> > > getting back the following exception,
> > > 
> > > Query Failed [Failed to execute main query]]; nested:  
> > > ClassCastException[org.\*\*elasticsearch.index.fielddata.\*\*ScriptDocValues$NumericLong  
> > > cannot be cast to java.lang.Number]; }
> > > 
> > > On Thursday, October 10, 2013 8:10:44 AM UTC+1, Alexander Reelsen wrote:
> > > 
> > > > Hey,
> > > > 
> > > > range facets also support key\_script and value\_script parameters. There  
> > > > is a simple example for the terms facet at [http://www.elasticsearch](http://www.elasticsearch).\*\*  
> > > > or\*\*g/guide/en/elasticsearch/ **refer** ence/current/search- **facets-**  
> > > > terms-facet.html[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-facet.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-facet.html)
> > > > 
> > > > Regarding key\_script and value\_script. It uses the key part for  
> > > > bucketing and the value for the range statistics. Take this (artificial)  
> > > > example
> > > > 
> > > > "posts\_tagging": {  
> > > > "range" : {  
> > > > "key\_script" : "doc['release\_date'].date. **year**",  
> > > > "value\_script" : "doc['tags'].size()",  
> > > > "ranges" : [  
> > > > { "to" : 1970 },  
> > > > { "from" : 1970, "to" : 1990 },  
> > > > { "from" : 1990 }  
> > > > ]  
> > > > }  
> > > > }
> > > > 
> > > > You could actually get statistics if the posts which have a tags array  
> > > > and a release date were more heavily tagged since 1990 onwards compared to  
> > > > earlier days.
> > > > 
> > > > Hope this helps...
> > > > 
> > > > --Alex
> > > > 
> > > > On Wed, Oct 9, 2013 at 6:05 PM, dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > 
> > > > > Thanks Alex, could I use this with range facets too. Are there any  
> > > > > examples anywhere?
> > > > > 
> > > > > On Wednesday, October 9, 2013 4:34:03 PM UTC+1, Alexander Reelsen  
> > > > > wrote:
> > > > > 
> > > > > > Hey,
> > > > > > 
> > > > > > you could use the terms facet in combination with a script which  
> > > > > > concatenates the fields together to create a unique. Obviously a bit slower  
> > > > > > than doing this on indexing time, but maybe sufficient in your case...
> > > > > > 
> > > > > > Hope this helps.
> > > > > > 
> > > > > > --Alex
> > > > > > 
> > > > > > On Wed, Oct 9, 2013 at 4:57 PM, dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > > > 
> > > > > > > Is there a way to group a facet count based on another property. For  
> > > > > > > example, if my data looks like this:
> > > > > > > 
> > > > > > > {  
> > > > > > > "book":{  
> > > > > > > "id": "1234",  
> > > > > > > "pages":[  
> > > > > > > {  
> > > > > > > "title": "elastic",  
> > > > > > > "images" : [  
> > > > > > > {  
> > > > > > > "name" : "some image",  
> > > > > > > "mimeType": "image/png",  
> > > > > > > },  
> > > > > > > {  
> > > > > > > "name" : "another image",  
> > > > > > > "mimeType": "image/png",  
> > > > > > > }  
> > > > > > > ]  
> > > > > > > }  
> > > > > > > ]  
> > > > > > > }  
> > > > > > > }
> > > > > > > 
> > > > > > > and in my model I have made "pages" and "images" nested types.
> > > > > > > 
> > > > > > > I want to be able to facet on the 'mimeType' property of the images  
> > > > > > > within the pages of the book (i.e. book.pages.images.mimeType), but for my  
> > > > > > > example data above this will show a facet count of 2 for the 'image/png'  
> > > > > > > mime type. Is there any way to group these two facets based on another  
> > > > > > > property, i.e. book.id so that 'image/png' facet will only show  
> > > > > > > only show a count of 1?
> > > > > > > 
> > > > > > > --  
> > > > > > > You received this message because you are subscribed to the Google  
> > > > > > > Groups "elasticsearch" group.  
> > > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > > send an email to elasticsearc...@\*\*googlegroups. **c** om.
> > > > > > > 
> > > > > > > For more options, visit [https://groups.google.com/\*\*grou](https://groups.google.com/**grou)\*\*\*\*  
> > > > > > > ps/opt\_out [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to the Google  
> > > > > > Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > > > an email to elasticsearc...@\*\*googlegroups.\*\*com.  
> > > > > > For more options, visit [https://groups.google.com/\*\*grou\*\*ps/opt\_out](https://groups.google.com/ **grou** ps/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > > .
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).  
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [October 11, 2013, 6:40am UTC](https://discuss.elastic.co/t/can-i-group-facet-counts/13887/9 "2013-10-11T06:40:11Z")

</div>

Yes, the ID is a String and I can't change that, will the script only work  
on a number?

On Friday, October 11, 2013 7:28:54 AM UTC+1, Alexander Reelsen wrote:

> Hey,
> 
> is your data of the field maybe stored as a string instead of a number in  
> the mapping? (Use the GET Mapping API to find out)...
> 
> --Alex
> 
> On Thu, Oct 10, 2013 at 5:55 PM, dan \<[dan.t...@gmail.com](mailto:dan.t...@gmail.com) \<javascript:\>\>wrote:
> 
> > Slightly different exception:
> > 
> > nested: ClassCastException[java.lang.String cannot be cast to  
> > java.lang.Number]
> > 
> > On Thursday, October 10, 2013 4:49:17 PM UTC+1, Alexander Reelsen wrote:
> > 
> > > Hey,
> > > 
> > > use doc['size'].value and doc['id'].value instead and see if it works.
> > > 
> > > --Alex
> > > 
> > > On Thu, Oct 10, 2013 at 5:28 PM, dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > 
> > > > Say I wanted to do a range facet on the image "size" property and group  
> > > > the facets by book "id"
> > > > 
> > > > {  
> > > > "book":{  
> > > > "id": "1234",  
> > > > "pages":[  
> > > > {  
> > > > "title": "elastic",  
> > > > "images" : [  
> > > > {  
> > > > "name" : "some image",  
> > > > "mimeType": "image/png",  
> > > > "size", 100
> > > > 
> > > > ```
> > > > },
> > > > {
> > > > "name" : "another image",
> > > > "mimeType": "image/png",
> > > > "size", 100
> > > > }
> > > > ]
> > > > }
> > > > ]
> > > > 
> > > > ```
> > > > 
> > > > }  
> > > > }
> > > > 
> > > > I have been trying this query
> > > > 
> > > > {  
> > > > "from" : 0,  
> > > > "size" : 1,  
> > > > "query" : {  
> > > > "query\_string" : {  
> > > > "query" : "_:_"  
> > > > }  
> > > > },  
> > > > "explain" : true,  
> > > > "facets" : {  
> > > > "contentSize" : {  
> > > > "range" : {  
> > > > "key\_script" : "doc['size']",  
> > > > "value\_script": "doc['id']",  
> > > > "ranges" : [ {  
> > > > "from" : 0.0,  
> > > > "to" : 1048576.0  
> > > > } ]  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > I don't think I clearly understand the 'value\_script' property. I am  
> > > > getting back the following exception,
> > > > 
> > > > Query Failed [Failed to execute main query]]; nested:  
> > > > ClassCastException[org.\*\*elasticsearch.index.fielddata.\*\*ScriptDocValues$NumericLong  
> > > > cannot be cast to java.lang.Number]; }
> > > > 
> > > > On Thursday, October 10, 2013 8:10:44 AM UTC+1, Alexander Reelsen wrote:
> > > > 
> > > > > Hey,
> > > > > 
> > > > > range facets also support key\_script and value\_script parameters.  
> > > > > There is a simple example for the terms facet at  
> > > > > [http://www.elasticsearch](http://www.elasticsearch). **or** g/guide/en/elasticsearch/ **refer**  
> > > > > ence/current/search-\*\*facets-\*\*terms-facet.html[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-facet.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-facet.html)
> > > > > 
> > > > > Regarding key\_script and value\_script. It uses the key part for  
> > > > > bucketing and the value for the range statistics. Take this (artificial)  
> > > > > example
> > > > > 
> > > > > "posts\_tagging": {  
> > > > > "range" : {  
> > > > > "key\_script" : "doc['release\_date'].date. **year**",  
> > > > > "value\_script" : "doc['tags'].size()",  
> > > > > "ranges" : [  
> > > > > { "to" : 1970 },  
> > > > > { "from" : 1970, "to" : 1990 },  
> > > > > { "from" : 1990 }  
> > > > > ]  
> > > > > }  
> > > > > }
> > > > > 
> > > > > You could actually get statistics if the posts which have a tags array  
> > > > > and a release date were more heavily tagged since 1990 onwards compared to  
> > > > > earlier days.
> > > > > 
> > > > > Hope this helps...
> > > > > 
> > > > > --Alex
> > > > > 
> > > > > On Wed, Oct 9, 2013 at 6:05 PM, dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > > 
> > > > > > Thanks Alex, could I use this with range facets too. Are there any  
> > > > > > examples anywhere?
> > > > > > 
> > > > > > On Wednesday, October 9, 2013 4:34:03 PM UTC+1, Alexander Reelsen  
> > > > > > wrote:
> > > > > > 
> > > > > > > Hey,
> > > > > > > 
> > > > > > > you could use the terms facet in combination with a script which  
> > > > > > > concatenates the fields together to create a unique. Obviously a bit slower  
> > > > > > > than doing this on indexing time, but maybe sufficient in your case...
> > > > > > > 
> > > > > > > Hope this helps.
> > > > > > > 
> > > > > > > --Alex
> > > > > > > 
> > > > > > > On Wed, Oct 9, 2013 at 4:57 PM, dan [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > > > > > 
> > > > > > > > Is there a way to group a facet count based on another property.  
> > > > > > > > For example, if my data looks like this:
> > > > > > > > 
> > > > > > > > {  
> > > > > > > > "book":{  
> > > > > > > > "id": "1234",  
> > > > > > > > "pages":[  
> > > > > > > > {  
> > > > > > > > "title": "elastic",  
> > > > > > > > "images" : [  
> > > > > > > > {  
> > > > > > > > "name" : "some image",  
> > > > > > > > "mimeType": "image/png",  
> > > > > > > > },  
> > > > > > > > {  
> > > > > > > > "name" : "another image",  
> > > > > > > > "mimeType": "image/png",  
> > > > > > > > }  
> > > > > > > > ]  
> > > > > > > > }  
> > > > > > > > ]  
> > > > > > > > }  
> > > > > > > > }
> > > > > > > > 
> > > > > > > > and in my model I have made "pages" and "images" nested types.
> > > > > > > > 
> > > > > > > > I want to be able to facet on the 'mimeType' property of the images  
> > > > > > > > within the pages of the book (i.e. book.pages.images.mimeType), but for my  
> > > > > > > > example data above this will show a facet count of 2 for the 'image/png'  
> > > > > > > > mime type. Is there any way to group these two facets based on another  
> > > > > > > > property, i.e. book.id so that 'image/png' facet will only show  
> > > > > > > > only show a count of 1?
> > > > > > > > 
> > > > > > > > --  
> > > > > > > > You received this message because you are subscribed to the Google  
> > > > > > > > Groups "elasticsearch" group.  
> > > > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > > > send an email to elasticsearc...@\*\*googlegroups. **c** om.
> > > > > > > > 
> > > > > > > > For more options, visit [https://groups.google.com/\*\*grou](https://groups.google.com/**grou)\*\*\*\*  
> > > > > > > > ps/opt\_out [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > > > > > 
> > > > > > > --  
> > > > > > > You received this message because you are subscribed to the Google  
> > > > > > > Groups "elasticsearch" group.  
> > > > > > > To unsubscribe from this group and stop receiving emails from it,  
> > > > > > > send an email to elasticsearc...@\*\*googlegroups.\*\*com.  
> > > > > > > For more options, visit [https://groups.google.com/\*\*grou\*\*ps/opt\_out](https://groups.google.com/ **grou** ps/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > > > .
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to the Google  
> > > > > Groups "elasticsearch" group.  
> > > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).  
> > > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > > .
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google Groups  
> > > "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send an  
> > > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:12am UTC](https://discuss.elastic.co/t/can-i-group-facet-counts/13887/10 "2017-07-06T02:12:54Z")

</div>


