# How to get the unique results from ES query

**URL:** <https://discuss.elastic.co/t/how-to-get-the-unique-results-from-es-query/71293>\
**Category:** Elasticsearch\
**Created:** [January 12, 2017, 12:00am UTC](https://discuss.elastic.co/t/how-to-get-the-unique-results-from-es-query/71293 "2017-01-12T00:00:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chunji08](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@chunji08](https://discuss.elastic.co/u/chunji08)\
**Post date:** [January 12, 2017, 12:00am UTC](https://discuss.elastic.co/t/how-to-get-the-unique-results-from-es-query/71293/1 "2017-01-12T00:00:06Z")

</div>

Hi All,  
I am using ES 5.1, and here is my curl command to trace the first 100 message in one index, something as:  
"  
curl "[http://localhost:9200/](http://localhost:9200/)\<my\_index\>/\_search?pretty=1&q=ERROR...&default\_operator=AND&\_source=path,message,@timestamp&size=..." -d  
'{  
"query": {  
"match": {  
"message": "\<search\_key\_word\>"  
}  
},  
"sort": [{ "@timestamp": { "order": "asc"}}]  
}  
}'  
".

And here is the sample of response I got ==\>  
"  
{  
"took" : 3,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 1805,  
"max\_score" : null,  
"hits" : [  
{  
"\_index" : "\<my\_index\_here\>",  
"\_type" : "jfk",  
"\_id" : "AVmNHSzFoBaEjBK5MkUa",  
"\_score" : null,  
"\_source" : {  
"path" : "...",  
"@timestamp" : "2017-01-11T10:40:13.903Z",  
"message" : "FAILED for reason 1 ... "  
},  
"sort" : [  
1484131213903  
]  
},  
....  
{  
"\_index" : "\<my\_index\_here\>",  
"\_type" : "jfk",  
"\_id" : "AVmNHSzFoBaEjBK5MkU1",  
"\_score" : null,  
"\_source" : {  
"path" : "...",  
"@timestamp" : "2017-01-11T10:40:13.903Z",  
"message" : "FAILED for reason X... "  
},  
"sort" : [  
1484131213903  
]  
} ] }}  
"

The question I have is, what the query would be, that in the response, the value of "message" part is unique ? I have googled for a while, but still no luck.

Appreciated if someone can help for that. Thanks a lot.

Chun

---

<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:** [February 9, 2017, 12:00am UTC](https://discuss.elastic.co/t/how-to-get-the-unique-results-from-es-query/71293/2 "2017-02-09T00:00:06Z")

</div>

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