# Grouping by non-numeric field

**URL:** <https://discuss.elastic.co/t/grouping-by-non-numeric-field/4117>\
**Category:** Elasticsearch\
**Created:** [March 16, 2011, 8:00pm UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-field/4117 "2011-03-16T20:00:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jason](https://discuss.elastic.co/u/jason)\
**Post date:** [March 16, 2011, 8:00pm UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-field/4117/1 "2011-03-16T20:00:46Z")

</div>

Hi,

I would like to write a query in ES that shows counts for each  
person's name, equivalent to the following SQL query:

select name, count() from people group by name;

I found a similar request here: [https://github.com/elasticsearch/elasticsearch/issues/#issue/539](https://github.com/elasticsearch/elasticsearch/issues/#issue/539)

Does this feature already exist in the most recent version of ES? If  
yes, which facet should I use? I looked at terms and histogram facets,  
and they don't seem to be appropriate.

If anyone has implemented this before, please share your knowledge.

Thank you,  
Eugene.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 17, 2011, 9:31am UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-field/4117/2 "2011-03-17T09:31:30Z")

</div>

Terms stats might be what you are after, its in master: [Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/closed#issue/705).  
On Wednesday, March 16, 2011 at 10:00 PM, eugene wrote:

> Hi,
> 
> I would like to write a query in ES that shows counts for each  
> person's name, equivalent to the following SQL query:
> 
> select name, count() from people group by name;
> 
> I found a similar request here: [Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/#issue/539)
> 
> Does this feature already exist in the most recent version of ES? If  
> yes, which facet should I use? I looked at terms and histogram facets,  
> and they don't seem to be appropriate.
> 
> If anyone has implemented this before, please share your knowledge.
> 
> Thank you,  
> Eugene.

---

<div class="post-metadata">

**Author:** ![jason](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jason](https://discuss.elastic.co/u/jason)\
**Post date:** [March 17, 2011, 5:21pm UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-field/4117/3 "2011-03-17T17:21:48Z")

</div>

I run the following query:

{  
"query" : {  
"match\_all": {}  
},  
"filter" : {  
"range" : {  
"timestamp" : {  
"from" : "2011-01-01",  
"to" : "2011-02-02",  
"include\_lower" : true,  
"include\_upper" : false  
}  
}  
},  
"facets" : {  
"url\_count\_stats" : {  
"terms\_stats" : {  
"key\_field" : "url",  
"value\_field" : "count"  
}  
}  
}  
}

and I am getting the exception:

{"error":"SearchPhaseExecutionException[Failed to execute phase  
[query], total f  
ailure; shardFailures {[B2ehMgT2TVeGgJtOVZLQJw][test][0]:  
SearchParseException[[  
test][0]: query[ConstantScore(_:_)],from[-1],size[-1]: Parse Failure  
[Failed to  
parse source [{ \t"query" : { \t\t"match\_all": {}\t },\t"filter  
" : {\t\t  
"range" : { \t\t\t"timestamp" : { \t\t\t\t"from" :  
"2011-01-01", \t\t\t  
\t"to" : "2011-02-02", \t\t\t\t"include\_lower" : true, \t\t\t\t  
"include  
\_upper" : false \t\t\t}\t\t} \t},\t"facets" : {\t\t"url\_count\_stats  
" : {\t  
t\t"terms\_stats" : {\t\t\t\t"key\_field" : "url",\t\t\t\t  
"value\_field" :  
"count"\t\t\t}\t\t}\t}}]]]; nested: SearchParseException[[test][0]:  
query[Cons  
tantScore(_:_)],from[-1],size[-1]: Parse Failure [No facet type found  
for [terms  
\_stats]]]; }{[B2ehMgT2TVeGgJtOVZLQJw][test][1]:  
SearchParseException[[test][1]:

On Mar 17, 2:31 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Terms stats might be what you are after, its in master:[Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/closed#issue/705).
> 
> On Wednesday, March 16, 2011 at 10:00 PM, eugene wrote:
> 
> > Hi,
> 
> > I would like to write a query in ES that shows counts for each  
> > person's name, equivalent to the following SQL query:
> 
> > select name, count() from people group by name;
> 
> > I found a similar request here:[Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/#issue/539)
> 
> > Does this feature already exist in the most recent version of ES? If  
> > yes, which facet should I use? I looked at terms and histogram facets,  
> > and they don't seem to be appropriate.
> 
> > If anyone has implemented this before, please share your knowledge.
> 
> > Thank you,  
> > Eugene.- Hide quoted text -
> 
> - Show quoted text -

---

<div class="post-metadata">

**Author:** ![jason](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jason](https://discuss.elastic.co/u/jason)\
**Post date:** [March 17, 2011, 6:30pm UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-field/4117/4 "2011-03-17T18:30:41Z")

</div>

Oh, I understand why I am getting this error. Because I need to  
download an update of Elasticsearch with termsstats package. Shay,  
could you tell me how I can do it from this page:

> <https://github.com/elastic/elasticsearch/commit/352cb74f960fe9d0c91cd44fa61474625e960e03>

Thank you,  
Eugene.

On Mar 17, 10:21 am, eugene [efur...@gmail.com](mailto:efur...@gmail.com) wrote:

> I run the following query:
> 
> {  
> "query" : {  
> "match\_all": {}  
> },  
> "filter" : {  
> "range" : {  
> "timestamp" : {  
> "from" : "2011-01-01",  
> "to" : "2011-02-02",  
> "include\_lower" : true,  
> "include\_upper" : false  
> }  
> }  
> },  
> "facets" : {  
> "url\_count\_stats" : {  
> "terms\_stats" : {  
> "key\_field" : "url",  
> "value\_field" : "count"  
> }  
> }  
> }
> 
> }
> 
> and I am getting the exception:
> 
> {"error":"SearchPhaseExecutionException[Failed to execute phase  
> [query], total f  
> ailure; shardFailures {[B2ehMgT2TVeGgJtOVZLQJw][test][0]:  
> SearchParseException[[  
> test][0]: query[ConstantScore(_:_)],from[-1],size[-1]: Parse Failure  
> [Failed to  
> parse source [{ \t"query" : { \t\t"match\_all": {}\t },\t"filter  
> " : {\t\t  
> "range" : { \t\t\t"timestamp" : { \t\t\t\t"from" :  
> "2011-01-01", \t\t\t  
> \t"to" : "2011-02-02", \t\t\t\t"include\_lower" : true, \t\t\t\t  
> "include  
> \_upper" : false \t\t\t}\t\t} \t},\t"facets" : {\t\t"url\_count\_stats  
> " : {\t  
> t\t"terms\_stats" : {\t\t\t\t"key\_field" : "url",\t\t\t\t  
> "value\_field" :  
> "count"\t\t\t}\t\t}\t}}]]]; nested: SearchParseException[[test][0]:  
> query[Cons  
> tantScore(_:_)],from[-1],size[-1]: Parse Failure [No facet type found  
> for [terms  
> \_stats]]]; }{[B2ehMgT2TVeGgJtOVZLQJw][test][1]:  
> SearchParseException[[test][1]:
> 
> On Mar 17, 2:31 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Terms stats might be what you are after, its in master:[Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/closed#issue/705).
> 
> > On Wednesday, March 16, 2011 at 10:00 PM, eugene wrote:
> > 
> > > Hi,
> 
> > > I would like to write a query in ES that shows counts for each  
> > > person's name, equivalent to the following SQL query:
> 
> > > select name, count() from people group by name;
> 
> > > I found a similar request here:[Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/#issue/539)
> 
> > > Does this feature already exist in the most recent version of ES? If  
> > > yes, which facet should I use? I looked at terms and histogram facets,  
> > > and they don't seem to be appropriate.
> 
> > > If anyone has implemented this before, please share your knowledge.
> 
> > > Thank you,  
> > > Eugene.- Hide quoted text -
> 
> > - Show quoted text -- Hide quoted text -
> 
> - Show quoted text -

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 17, 2011, 6:33pm UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-field/4117/5 "2011-03-17T18:33:19Z")

</div>

You will need to build elasticsearch from master. Once downloaded / git-cloned, you can run "gradlew release" from the root, and the distribution will eb under build/distributions.

> **[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.

On Thursday, March 17, 2011 at 8:30 PM, eugene wrote:

> Oh, I understand why I am getting this error. Because I need to  
> download an update of Elasticsearch with termsstats package. Shay,  
> could you tell me how I can do it from this page:
> 
> [Search: Terms Stats Facet, closes #705. · elastic/elasticsearch@352cb74 · GitHub](https://github.com/elasticsearch/elasticsearch/commit/352cb74f960fe9d0c91cd44fa61474625e960e03)
> 
> Thank you,  
> Eugene.
> 
> On Mar 17, 10:21 am, eugene [efur...@gmail.com](mailto:efur...@gmail.com) wrote:
> 
> > I run the following query:
> > 
> > {  
> > "query" : {  
> > "match\_all": {}  
> > },  
> > "filter" : {  
> > "range" : {  
> > "timestamp" : {  
> > "from" : "2011-01-01",  
> > "to" : "2011-02-02",  
> > "include\_lower" : true,  
> > "include\_upper" : false  
> > }  
> > }  
> > },  
> > "facets" : {  
> > "url\_count\_stats" : {  
> > "terms\_stats" : {  
> > "key\_field" : "url",  
> > "value\_field" : "count"  
> > }  
> > }  
> > }
> > 
> > }
> > 
> > and I am getting the exception:
> > 
> > {"error":"SearchPhaseExecutionException[Failed to execute phase  
> > [query], total f  
> > ailure; shardFailures {[B2ehMgT2TVeGgJtOVZLQJw][test][0]:  
> > SearchParseException[[  
> > test][0]: query[ConstantScore(_:_)],from[-1],size[-1]: Parse Failure  
> > [Failed to  
> > parse source [{ \t"query" : { \t\t"match\_all": {}\t },\t"filter  
> > " : {\t\t  
> > "range" : { \t\t\t"timestamp" : { \t\t\t\t"from" :  
> > "2011-01-01", \t\t\t  
> > \t"to" : "2011-02-02", \t\t\t\t"include\_lower" : true, \t\t\t\t  
> > "include  
> > \_upper" : false \t\t\t}\t\t} \t},\t"facets" : {\t\t"url\_count\_stats  
> > " : {\t  
> > t\t"terms\_stats" : {\t\t\t\t"key\_field" : "url",\t\t\t\t  
> > "value\_field" :  
> > "count"\t\t\t}\t\t}\t}}]]]; nested: SearchParseException[[test][0]:  
> > query[Cons  
> > tantScore(_:_)],from[-1],size[-1]: Parse Failure [No facet type found  
> > for [terms  
> > \_stats]]]; }{[B2ehMgT2TVeGgJtOVZLQJw][test][1]:  
> > SearchParseException[[test][1]:
> > 
> > On Mar 17, 2:31 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > 
> > > Terms stats might be what you are after, its in master:[Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/closed#issue/705).
> > 
> > > On Wednesday, March 16, 2011 at 10:00 PM, eugene wrote:
> > > 
> > > > Hi,
> > 
> > > > I would like to write a query in ES that shows counts for each  
> > > > person's name, equivalent to the following SQL query:
> > 
> > > > select name, count() from people group by name;
> > 
> > > > I found a similar request here:[Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/#issue/539)
> > 
> > > > Does this feature already exist in the most recent version of ES? If  
> > > > yes, which facet should I use? I looked at terms and histogram facets,  
> > > > and they don't seem to be appropriate.
> > 
> > > > If anyone has implemented this before, please share your knowledge.
> > 
> > > > Thank you,  
> > > > Eugene.- Hide quoted text -
> > 
> > > - Show quoted text -- Hide quoted text -
> > 
> > - Show quoted text -

---

<div class="post-metadata">

**Author:** ![jason](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jason](https://discuss.elastic.co/u/jason)\
**Post date:** [March 17, 2011, 9:18pm UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-field/4117/6 "2011-03-17T21:18:18Z")

</div>

Than you, Shay. I built a new version of elasticsearch, and it  
contains updated libraries. Is the version 0.16.0 already in maven  
repository? I could probably change the version of my elasticsearch  
artifact and that would easily work. Please let me know if there is  
another workaround, since I am only using maven and want to avoid  
adding individual jar files to my project.

On Mar 17, 11:33 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> You will need to build elasticsearch from master. Once downloaded / git-cloned, you can run "gradlew release" from the root, and the distribution will eb under build/distributions.
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/appendix/building-from-source.html)
> 
> On Thursday, March 17, 2011 at 8:30 PM, eugene wrote:
> 
> > Oh, I understand why I am getting this error. Because I need to  
> > download an update of Elasticsearch with termsstats package. Shay,  
> > could you tell me how I can do it from this page:
> 
> > [Search: Terms Stats Facet, closes #705. · elastic/elasticsearch@352cb74 · GitHub](https://github.com/elasticsearch/elasticsearch/commit/352cb74f960fe9d)...
> 
> > Thank you,  
> > Eugene.
> 
> > On Mar 17, 10:21 am, eugene [efur...@gmail.com](mailto:efur...@gmail.com) wrote:
> > 
> > > I run the following query:
> 
> > > {  
> > > "query" : {  
> > > "match\_all": {}  
> > > },  
> > > "filter" : {  
> > > "range" : {  
> > > "timestamp" : {  
> > > "from" : "2011-01-01",  
> > > "to" : "2011-02-02",  
> > > "include\_lower" : true,  
> > > "include\_upper" : false  
> > > }  
> > > }  
> > > },  
> > > "facets" : {  
> > > "url\_count\_stats" : {  
> > > "terms\_stats" : {  
> > > "key\_field" : "url",  
> > > "value\_field" : "count"  
> > > }  
> > > }  
> > > }
> 
> > > }
> 
> > > and I am getting the exception:
> 
> > > {"error":"SearchPhaseExecutionException[Failed to execute phase  
> > > [query], total f  
> > > ailure; shardFailures {[B2ehMgT2TVeGgJtOVZLQJw][test][0]:  
> > > SearchParseException[[  
> > > test][0]: query[ConstantScore(_:_)],from[-1],size[-1]: Parse Failure  
> > > [Failed to  
> > > parse source [{ \t"query" : { \t\t"match\_all": {}\t },\t"filter  
> > > " : {\t\t  
> > > "range" : { \t\t\t"timestamp" : { \t\t\t\t"from" :  
> > > "2011-01-01", \t\t\t  
> > > \t"to" : "2011-02-02", \t\t\t\t"include\_lower" : true, \t\t\t\t  
> > > "include  
> > > \_upper" : false \t\t\t}\t\t} \t},\t"facets" : {\t\t"url\_count\_stats  
> > > " : {\t  
> > > t\t"terms\_stats" : {\t\t\t\t"key\_field" : "url",\t\t\t\t  
> > > "value\_field" :  
> > > "count"\t\t\t}\t\t}\t}}]]]; nested: SearchParseException[[test][0]:  
> > > query[Cons  
> > > tantScore(_:_)],from[-1],size[-1]: Parse Failure [No facet type found  
> > > for [terms  
> > > \_stats]]]; }{[B2ehMgT2TVeGgJtOVZLQJw][test][1]:  
> > > SearchParseException[[test][1]:
> 
> > > On Mar 17, 2:31 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > > > Terms stats might be what you are after, its in master:[Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/closed#issue/705).
> 
> > > > On Wednesday, March 16, 2011 at 10:00 PM, eugene wrote:
> > > > 
> > > > > Hi,
> 
> > > > > I would like to write a query in ES that shows counts for each  
> > > > > person's name, equivalent to the following SQL query:
> 
> > > > > select name, count() from people group by name;
> 
> > > > > I found a similar request here:[Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/#issue/539)
> 
> > > > > Does this feature already exist in the most recent version of ES? If  
> > > > > yes, which facet should I use? I looked at terms and histogram facets,  
> > > > > and they don't seem to be appropriate.
> 
> > > > > If anyone has implemented this before, please share your knowledge.
> 
> > > > > Thank you,  
> > > > > Eugene.- Hide quoted text -
> 
> > > > - Show quoted text -- Hide quoted text -
> 
> > > - Show quoted text -- Hide quoted text -
> 
> - Show quoted text -

---

<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:** [March 17, 2011, 9:21pm UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-field/4117/7 "2011-03-17T21:21:50Z")

</div>

There is a version in the Sonatype snapshot repo:

[https://oss.sonatype.org/content/repositories/snapshots/org/elasticsearch/elasticsearch/](https://oss.sonatype.org/content/repositories/snapshots/org/elasticsearch/elasticsearch/)

On Thu, Mar 17, 2011 at 5:18 PM, eugene [efurman@gmail.com](mailto:efurman@gmail.com) wrote:

> Than you, Shay. I built a new version of elasticsearch, and it  
> contains updated libraries. Is the version 0.16.0 already in maven  
> repository? I could probably change the version of my elasticsearch  
> artifact and that would easily work. Please let me know if there is  
> another workaround, since I am only using maven and want to avoid  
> adding individual jar files to my project.
> 
> On Mar 17, 11:33 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > You will need to build elasticsearch from master. Once downloaded /  
> > git-cloned, you can run "gradlew release" from the root, and the  
> > distribution will eb under build/distributions.
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/appendix/building-from-source.html)
> > 
> > On Thursday, March 17, 2011 at 8:30 PM, eugene wrote:
> > 
> > > Oh, I understand why I am getting this error. Because I need to  
> > > download an update of Elasticsearch with termsstats package. Shay,  
> > > could you tell me how I can do it from this page:
> > 
> > > [Search: Terms Stats Facet, closes #705. · elastic/elasticsearch@352cb74 · GitHub](https://github.com/elasticsearch/elasticsearch/commit/352cb74f960fe9d).  
> > > ..
> > 
> > > Thank you,  
> > > Eugene.
> > 
> > > On Mar 17, 10:21 am, eugene [efur...@gmail.com](mailto:efur...@gmail.com) wrote:
> > > 
> > > > I run the following query:
> > 
> > > > {  
> > > > "query" : {  
> > > > "match\_all": {}  
> > > > },  
> > > > "filter" : {  
> > > > "range" : {  
> > > > "timestamp" : {  
> > > > "from" : "2011-01-01",  
> > > > "to" : "2011-02-02",  
> > > > "include\_lower" : true,  
> > > > "include\_upper" : false  
> > > > }  
> > > > }  
> > > > },  
> > > > "facets" : {  
> > > > "url\_count\_stats" : {  
> > > > "terms\_stats" : {  
> > > > "key\_field" : "url",  
> > > > "value\_field" : "count"  
> > > > }  
> > > > }  
> > > > }
> > 
> > > > }
> > 
> > > > and I am getting the exception:
> > 
> > > > {"error":"SearchPhaseExecutionException[Failed to execute phase  
> > > > [query], total f  
> > > > ailure; shardFailures {[B2ehMgT2TVeGgJtOVZLQJw][test][0]:  
> > > > SearchParseException[[  
> > > > test][0]: query[ConstantScore(_:_)],from[-1],size[-1]: Parse Failure  
> > > > [Failed to  
> > > > parse source [{ \t"query" : { \t\t"match\_all": {}\t },\t"filter  
> > > > " : {\t\t  
> > > > "range" : { \t\t\t"timestamp" : { \t\t\t\t"from" :  
> > > > "2011-01-01", \t\t\t  
> > > > \t"to" : "2011-02-02", \t\t\t\t"include\_lower" : true, \t\t\t\t  
> > > > "include  
> > > > \_upper" : false \t\t\t}\t\t} \t},\t"facets" :  
> > > > {\t\t"url\_count\_stats  
> > > > " : {\t  
> > > > t\t"terms\_stats" : {\t\t\t\t"key\_field" : "url",\t\t\t\t  
> > > > "value\_field" :  
> > > > "count"\t\t\t}\t\t}\t}}]]]; nested: SearchParseException[[test][0]:  
> > > > query[Cons  
> > > > tantScore(_:_)],from[-1],size[-1]: Parse Failure [No facet type found  
> > > > for [terms  
> > > > \_stats]]]; }{[B2ehMgT2TVeGgJtOVZLQJw][test][1]:  
> > > > SearchParseException[[test][1]:
> > 
> > > > On Mar 17, 2:31 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > 
> > > > > Terms stats might be what you are after, its in master:  
> > > > > [Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/closed#issue/705).
> > 
> > > > > On Wednesday, March 16, 2011 at 10:00 PM, eugene wrote:
> > > > > 
> > > > > > Hi,
> > 
> > > > > > I would like to write a query in ES that shows counts for each  
> > > > > > person's name, equivalent to the following SQL query:
> > 
> > > > > > select name, count() from people group by name;
> > 
> > > > > > I found a similar request here:  
> > > > > > [Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/#issue/539)
> > 
> > > > > > Does this feature already exist in the most recent version of ES?  
> > > > > > If  
> > > > > > yes, which facet should I use? I looked at terms and histogram  
> > > > > > facets,  
> > > > > > and they don't seem to be appropriate.
> > 
> > > > > > If anyone has implemented this before, please share your  
> > > > > > knowledge.
> > 
> > > > > > Thank you,  
> > > > > > Eugene.- Hide quoted text -
> > 
> > > > > - Show quoted text -- Hide quoted text -
> > 
> > > > - Show quoted text -- Hide quoted text -
> > 
> > - Show quoted text -

---

<div class="post-metadata">

**Author:** ![jason](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jason](https://discuss.elastic.co/u/jason)\
**Post date:** [March 17, 2011, 10:26pm UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-field/4117/8 "2011-03-17T22:26:12Z")

</div>

Great, Ivan. It worked for me and I can import termsStats facet into  
my project!

I have another problem. What should I use for value\_field in  
terms\_stats facet if none of my fields are numeric?

Thanks,  
Eugene.

On Mar 17, 2:21 pm, Ivan Brusic [i...@brusic.com](mailto:i...@brusic.com) wrote:

> There is a version in the Sonatype snapshot repo:
> 
> [https://oss.sonatype.org/content/repositories/snapshots/org/elasticse](https://oss.sonatype.org/content/repositories/snapshots/org/elasticse)...
> 
> On Thu, Mar 17, 2011 at 5:18 PM, eugene [efur...@gmail.com](mailto:efur...@gmail.com) wrote:
> 
> > Than you, Shay. I built a new version of elasticsearch, and it  
> > contains updated libraries. Is the version 0.16.0 already in maven  
> > repository? I could probably change the version of my elasticsearch  
> > artifact and that would easily work. Please let me know if there is  
> > another workaround, since I am only using maven and want to avoid  
> > adding individual jar files to my project.
> 
> > On Mar 17, 11:33 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > 
> > > You will need to build elasticsearch from master. Once downloaded /  
> > > git-cloned, you can run "gradlew release" from the root, and the  
> > > distribution will eb under build/distributions.
> 
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/appendix/building-from-source.html)
> 
> > > On Thursday, March 17, 2011 at 8:30 PM, eugene wrote:
> 
> > > > Oh, I understand why I am getting this error. Because I need to  
> > > > download an update of Elasticsearch with termsstats package. Shay,  
> > > > could you tell me how I can do it from this page:
> 
> > > > [Search: Terms Stats Facet, closes #705. · elastic/elasticsearch@352cb74 · GitHub](https://github.com/elasticsearch/elasticsearch/commit/352cb74f960fe9d).  
> > > > ..
> 
> > > > Thank you,  
> > > > Eugene.
> 
> > > > On Mar 17, 10:21 am, eugene [efur...@gmail.com](mailto:efur...@gmail.com) wrote:
> > > > 
> > > > > I run the following query:
> 
> > > > > {  
> > > > > "query" : {  
> > > > > "match\_all": {}  
> > > > > },  
> > > > > "filter" : {  
> > > > > "range" : {  
> > > > > "timestamp" : {  
> > > > > "from" : "2011-01-01",  
> > > > > "to" : "2011-02-02",  
> > > > > "include\_lower" : true,  
> > > > > "include\_upper" : false  
> > > > > }  
> > > > > }  
> > > > > },  
> > > > > "facets" : {  
> > > > > "url\_count\_stats" : {  
> > > > > "terms\_stats" : {  
> > > > > "key\_field" : "url",  
> > > > > "value\_field" : "count"  
> > > > > }  
> > > > > }  
> > > > > }
> 
> > > > > }
> 
> > > > > and I am getting the exception:
> 
> > > > > {"error":"SearchPhaseExecutionException[Failed to execute phase  
> > > > > [query], total f  
> > > > > ailure; shardFailures {[B2ehMgT2TVeGgJtOVZLQJw][test][0]:  
> > > > > SearchParseException[[  
> > > > > test][0]: query[ConstantScore(_:_)],from[-1],size[-1]: Parse Failure  
> > > > > [Failed to  
> > > > > parse source [{ \t"query" : { \t\t"match\_all": {}\t },\t"filter  
> > > > > " : {\t\t  
> > > > > "range" : { \t\t\t"timestamp" : { \t\t\t\t"from" :  
> > > > > "2011-01-01", \t\t\t  
> > > > > \t"to" : "2011-02-02", \t\t\t\t"include\_lower" : true, \t\t\t\t  
> > > > > "include  
> > > > > \_upper" : false \t\t\t}\t\t} \t},\t"facets" :  
> > > > > {\t\t"url\_count\_stats  
> > > > > " : {\t  
> > > > > t\t"terms\_stats" : {\t\t\t\t"key\_field" : "url",\t\t\t\t  
> > > > > "value\_field" :  
> > > > > "count"\t\t\t}\t\t}\t}}]]]; nested: SearchParseException[[test][0]:  
> > > > > query[Cons  
> > > > > tantScore(_:_)],from[-1],size[-1]: Parse Failure [No facet type found  
> > > > > for [terms  
> > > > > \_stats]]]; }{[B2ehMgT2TVeGgJtOVZLQJw][test][1]:  
> > > > > SearchParseException[[test][1]:
> 
> > > > > On Mar 17, 2:31 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > > > > > Terms stats might be what you are after, its in master:  
> > > > > > [Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/closed#issue/705).
> 
> > > > > > On Wednesday, March 16, 2011 at 10:00 PM, eugene wrote:
> > > > > > 
> > > > > > > Hi,
> 
> > > > > > > I would like to write a query in ES that shows counts for each  
> > > > > > > person's name, equivalent to the following SQL query:
> 
> > > > > > > select name, count() from people group by name;
> 
> > > > > > > I found a similar request here:  
> > > > > > > [Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/#issue/539)
> 
> > > > > > > Does this feature already exist in the most recent version of ES?  
> > > > > > > If  
> > > > > > > yes, which facet should I use? I looked at terms and histogram  
> > > > > > > facets,  
> > > > > > > and they don't seem to be appropriate.
> 
> > > > > > > If anyone has implemented this before, please share your  
> > > > > > > knowledge.
> 
> > > > > > > Thank you,  
> > > > > > > Eugene.- Hide quoted text -
> 
> > > > > > - Show quoted text -- Hide quoted text -
> 
> > > > > - Show quoted text -- Hide quoted text -
> 
> > > - Show quoted text -- Hide quoted text -
> 
> - Show quoted text -

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [March 19, 2011, 6:16am UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-field/4117/9 "2011-03-19T06:16:48Z")

</div>

You can also use 'gradlew release install' to build and install  
elasticsearch SNAPSHOT into your local mvn repo. Then you can use it for  
your local development. Note that gradle should be able to delegate to mvn  
goals so I think whatever you can do with mvn you should be able to do with  
gradle too.

Regards,  
Lukas  
Dne 17.3.2011 22:18 "eugene" [efurman@gmail.com](mailto:efurman@gmail.com) napsal(a):

> Than you, Shay. I built a new version of elasticsearch, and it  
> contains updated libraries. Is the version 0.16.0 already in maven  
> repository? I could probably change the version of my elasticsearch  
> artifact and that would easily work. Please let me know if there is  
> another workaround, since I am only using maven and want to avoid  
> adding individual jar files to my project.
> 
> On Mar 17, 11:33 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > You will need to build elasticsearch from master. Once downloaded /  
> > git-cloned, you can run "gradlew release" from the root, and the  
> > distribution will eb under build/distributions.
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/appendix/building-from-source.html)
> > 
> > On Thursday, March 17, 2011 at 8:30 PM, eugene wrote:
> > 
> > > Oh, I understand why I am getting this error. Because I need to  
> > > download an update of Elasticsearch with termsstats package. Shay,  
> > > could you tell me how I can do it from this page:
> > 
> > > [Search: Terms Stats Facet, closes #705. · elastic/elasticsearch@352cb74 · GitHub](https://github.com/elasticsearch/elasticsearch/commit/352cb74f960fe9d)...
> > 
> > > Thank you,  
> > > Eugene.
> > 
> > > On Mar 17, 10:21 am, eugene [efur...@gmail.com](mailto:efur...@gmail.com) wrote:
> > > 
> > > > I run the following query:
> > 
> > > > {  
> > > > "query" : {  
> > > > "match\_all": {}  
> > > > },  
> > > > "filter" : {  
> > > > "range" : {  
> > > > "timestamp" : {  
> > > > "from" : "2011-01-01",  
> > > > "to" : "2011-02-02",  
> > > > "include\_lower" : true,  
> > > > "include\_upper" : false  
> > > > }  
> > > > }  
> > > > },  
> > > > "facets" : {  
> > > > "url\_count\_stats" : {  
> > > > "terms\_stats" : {  
> > > > "key\_field" : "url",  
> > > > "value\_field" : "count"  
> > > > }  
> > > > }  
> > > > }
> > 
> > > > }
> > 
> > > > and I am getting the exception:
> > 
> > > > {"error":"SearchPhaseExecutionException[Failed to execute phase  
> > > > [query], total f  
> > > > ailure; shardFailures {[B2ehMgT2TVeGgJtOVZLQJw][test][0]:  
> > > > SearchParseException[[  
> > > > test][0]: query[ConstantScore(_:_)],from[-1],size[-1]: Parse Failure  
> > > > [Failed to  
> > > > parse source [{ \t"query" : { \t\t"match\_all": {}\t },\t"filter  
> > > > " : {\t\t  
> > > > "range" : { \t\t\t"timestamp" : { \t\t\t\t"from" :  
> > > > "2011-01-01", \t\t\t  
> > > > \t"to" : "2011-02-02", \t\t\t\t"include\_lower" : true, \t\t\t\t  
> > > > "include  
> > > > \_upper" : false \t\t\t}\t\t} \t},\t"facets" :  
> > > > {\t\t"url\_count\_stats  
> > > > " : {\t  
> > > > t\t"terms\_stats" : {\t\t\t\t"key\_field" : "url",\t\t\t\t  
> > > > "value\_field" :  
> > > > "count"\t\t\t}\t\t}\t}}]]]; nested: SearchParseException[[test][0]:  
> > > > query[Cons  
> > > > tantScore(_:_)],from[-1],size[-1]: Parse Failure [No facet type found  
> > > > for [terms  
> > > > \_stats]]]; }{[B2ehMgT2TVeGgJtOVZLQJw][test][1]:  
> > > > SearchParseException[[test][1]:
> > 
> > > > On Mar 17, 2:31 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > 
> > > > > Terms stats might be what you are after, its in master:  
> > > > > [Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/closed#issue/705).
> > 
> > > > > On Wednesday, March 16, 2011 at 10:00 PM, eugene wrote:
> > > > > 
> > > > > > Hi,
> > 
> > > > > > I would like to write a query in ES that shows counts for each  
> > > > > > person's name, equivalent to the following SQL query:
> > 
> > > > > > select name, count() from people group by name;
> > 
> > > > > > I found a similar request here:  
> > > > > > [Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/#issue/539)
> > 
> > > > > > Does this feature already exist in the most recent version of ES?  
> > > > > > If  
> > > > > > yes, which facet should I use? I looked at terms and histogram  
> > > > > > facets,  
> > > > > > and they don't seem to be appropriate.
> > 
> > > > > > If anyone has implemented this before, please share your  
> > > > > > knowledge.
> > 
> > > > > > Thank you,  
> > > > > > Eugene.- Hide quoted text -
> > 
> > > > > - Show quoted text -- Hide quoted text -
> > 
> > > > - Show quoted text -- Hide quoted text -
> > 
> > - Show quoted text -

---

<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, 4:09am UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-field/4117/10 "2017-07-06T04:09:35Z")

</div>


