# Implementing SELECT distinct user\_name FROM index?

**URL:** <https://discuss.elastic.co/t/implementing-select-distinct-user-name-from-index/15616>\
**Category:** Elasticsearch\
**Created:** [February 5, 2014, 1:09pm UTC](https://discuss.elastic.co/t/implementing-select-distinct-user-name-from-index/15616 "2014-02-05T13:09:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oliver\_B\_Fischer](https://avatars.discourse-cdn.com/v4/letter/o/f04885/32.png) [@Oliver\_B\_Fischer](https://discuss.elastic.co/u/Oliver_B_Fischer)\
**Post date:** [February 5, 2014, 1:09pm UTC](https://discuss.elastic.co/t/implementing-select-distinct-user-name-from-index/15616/1 "2014-02-05T13:09:34Z")

</div>

Hi,

after reading the docs and googling for a while I got the impression it  
is not possible to ask ElasticSearch for a distinct values of a document  
field. I know the terms facet but it won't help me to return 100,000  
values. Right?

So is there another way to ask such kind of questions? At the moment I  
see only two possibilites: a) SQL and a RDBMS or b) fetching all  
relevant documents ordered by the desired field and kicking out  
duplicates by hand.

Bye,

Oliver

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/52F2380E.7050706%40swe-blog.net](https://groups.google.com/d/msgid/elasticsearch/52F2380E.7050706%40swe-blog.net).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [February 5, 2014, 4:50pm UTC](https://discuss.elastic.co/t/implementing-select-distinct-user-name-from-index/15616/2 "2014-02-05T16:50:24Z")

</div>

I think for 100k, it is still OK to use a terms facet. This is going to  
generate some network traffic but the issue would be the same with a RDBMS  
anyway. However, I wouldn't recommend using sorting and kicking out  
duplicates: this will either require deep paging or getting all results in  
a single large page which are two things that would perform badly.

On Wed, Feb 5, 2014 at 2:09 PM, Oliver B. Fischer [mailsink@swe-blog.net](mailto:mailsink@swe-blog.net)wrote:

> Hi,
> 
> after reading the docs and googling for a while I got the impression it is  
> not possible to ask Elasticsearch for a distinct values of a document  
> field. I know the terms facet but it won't help me to return 100,000  
> values. Right?
> 
> So is there another way to ask such kind of questions? At the moment I see  
> only two possibilites: a) SQL and a RDBMS or b) fetching all relevant  
> documents ordered by the desired field and kicking out duplicates by hand.
> 
> Bye,
> 
> Oliver
> 
> --  
> 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).  
> To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> msgid/elasticsearch/52F2380E.7050706%[40swe-blog.net](http://40swe-blog.net).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Adrien Grand

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6haNNi%3Dbj0VkL3Gxzy\_iw%2BMYd%2B4jZGMUz1gwL36rtyjA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6haNNi%3Dbj0VkL3Gxzy_iw%2BMYd%2B4jZGMUz1gwL36rtyjA%40mail.gmail.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, 1:52am UTC](https://discuss.elastic.co/t/implementing-select-distinct-user-name-from-index/15616/3 "2017-07-06T01:52:22Z")

</div>


