# Grouping by non-numeric fields

**URL:** <https://discuss.elastic.co/t/grouping-by-non-numeric-fields/4115>\
**Category:** Elasticsearch\
**Created:** [March 16, 2011, 7:19pm UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-fields/4115 "2011-03-16T19:19:50Z")\
**Posts on this page:** 3\
**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, 7:19pm UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-fields/4115/1 "2011-03-16T19:19:50Z")

</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:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [March 18, 2011, 12:26am UTC](https://discuss.elastic.co/t/grouping-by-non-numeric-fields/4115/2 "2011-03-18T00:26:38Z")

</div>

Term facets should be what you are looking for. You may have to use a  
multifield depending on your current analyzer. You'd probably want to  
use a keyword analyzer on the field you facet on.

Regards,  
Paul

On Mar 16, 1:19 pm, eugene [efur...@gmail.com](mailto:efur...@gmail.com) 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:** ![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-fields/4115/3 "2017-07-06T04:09:44Z")

</div>


