# Terms query return distinct field results

**URL:** https://discuss.elastic.co/t/terms-query-return-distinct-field-results/209950
**Category:** Elasticsearch
**Created:** [November 29, 2019, 9:56am UTC](https://discuss.elastic.co/t/terms-query-return-distinct-field-results/209950 "2019-11-29T09:56:18Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![hackerwin7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hackerwin7/32/43223_2.png) [@hackerwin7](https://discuss.elastic.co/u/hackerwin7)
#### Post date: [November 29, 2019, 10:32am UTC](https://discuss.elastic.co/t/terms-query-return-distinct-field-results/209950/6 "2019-11-29T10:32:46Z")

</div>

> [@How Can I Perform a Distinct Query?](https://discuss.elastic.co/t/how-can-i-perform-a-distinct-query/12539):
>
> Hi Guys, I'm a new ElasticSearch user, and need some help selecting only documents with a distinct field. I've got an index of documents which look something like the following: { "last\_name": "Degges", "first\_name": "Randall", "state": "CA", } I'm trying to return a list of de-duplicated documents which contain the same last name. For instance -- if I had three documents, two with a "last\_name" field of "Degges" and one with a "last\_name" field of "Perez", I'd want to return only tw…

similar to this topic, we just want to return a unique list of documents in terms query

---

_[View the full topic](https://discuss.elastic.co/t/terms-query-return-distinct-field-results/209950)._
