# Fetching unique data

**URL:** <https://discuss.elastic.co/t/fetching-unique-data/93354>\
**Category:** Elasticsearch\
**Created:** [July 17, 2017, 8:12am UTC](https://discuss.elastic.co/t/fetching-unique-data/93354 "2017-07-17T08:12:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![contact.pawan](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@contact.pawan](https://discuss.elastic.co/u/contact.pawan)\
**Post date:** [July 17, 2017, 8:12am UTC](https://discuss.elastic.co/t/fetching-unique-data/93354/1 "2017-07-17T08:12:59Z")

</div>

Hi All,  
I have following data  
ID: 1, fldname: pawan  
ID: 1, fldname: pawan1  
ID: 1, fldname: pawan2  
ID: 2, fldname: pawan3  
ID: 3, fldname: pawan4  
ID: 4, fldname: pawan5

I am trying to get unique data based on ID field, similar to what we get in MySQL while firing group by queries like:  
select \* from table\_name where fldname like 'pawan%' group by ID  
This will return unique values. Same works in sphinx search when we use group by function.

Is there any way to get unique values in elasticsearch..?

Below is my sample mapping:  
"mappings": {  
"my\_type": {  
"properties": {  
"docid": {  
"type": "keyword"  
},  
"flgname": {  
"type": "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:** [August 14, 2017, 8:13am UTC](https://discuss.elastic.co/t/fetching-unique-data/93354/2 "2017-08-14T08:13:27Z")

</div>

Closed on August 14, 2017, 8:13am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
