# Distinct Values for Phrases Help

**URL:** <https://discuss.elastic.co/t/distinct-values-for-phrases-help/29924>\
**Category:** Elasticsearch\
**Created:** [September 24, 2015, 3:31pm UTC](https://discuss.elastic.co/t/distinct-values-for-phrases-help/29924 "2015-09-24T15:31:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdb70](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jdb70](https://discuss.elastic.co/u/jdb70)\
**Post date:** [September 24, 2015, 3:31pm UTC](https://discuss.elastic.co/t/distinct-values-for-phrases-help/29924/1 "2015-09-24T15:31:38Z")

</div>

Hello, I am indexing a document that has error message as a field. The error message of course could be a phrase. I am using term aggregation to determine the unique error messages that have occurred but the aggregation is returning unique terms within the field. For example, for 'system error', I am getting 'system' as a term and 'error' as a term. How can I get elasticsearch to return phrases as unique terms?

Thanks in advance for your help.

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [September 24, 2015, 3:53pm UTC](https://discuss.elastic.co/t/distinct-values-for-phrases-help/29924/2 "2015-09-24T15:53:20Z")

</div>

Look at [shingles](https://www.elastic.co/guide/en/elasticsearch/reference/1.4/analysis-shingle-tokenfilter.html). They can combine multiple tokens into a single token. You could combine this with a [keepwords list](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-keep-words-tokenfilter.html) if you only wanted to hunt for specific phrases and ignore all others. You probably would want to copy the text to a different field to get this separate analysis run but preserve regular, full-text search over the original field values.

---

<div class="post-metadata">

**Author:** ![jdb70](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jdb70](https://discuss.elastic.co/u/jdb70)\
**Post date:** [September 24, 2015, 3:59pm UTC](https://discuss.elastic.co/t/distinct-values-for-phrases-help/29924/3 "2015-09-24T15:59:21Z")

</div>

What I am trying to do is find all unique error messages with number of times they have occurred on a given day. I am not sure if shingles would help.

Thanks.

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [September 24, 2015, 5:21pm UTC](https://discuss.elastic.co/t/distinct-values-for-phrases-help/29924/4 "2015-09-24T17:21:35Z")

</div>

Do you just want to not tokenize? You can simply mark the field as [not analyzed](https://www.elastic.co/guide/en/elasticsearch/guide/current/mapping-intro.html). Are you trying to extract something in the field (ie parse the error messages out) then you'll probably need to do that outside of Elasticsearch.

Hope that helps,

---

<div class="post-metadata">

**Author:** ![jdb70](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jdb70](https://discuss.elastic.co/u/jdb70)\
**Post date:** [September 25, 2015, 3:14pm UTC](https://discuss.elastic.co/t/distinct-values-for-phrases-help/29924/5 "2015-09-25T15:14:30Z")

</div>

I ended up doing this outside of elasticsearch. I am retrieving all the error messages and going through the retrieved values to get the unique values.

---

<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 5, 2017, 11:48pm UTC](https://discuss.elastic.co/t/distinct-values-for-phrases-help/29924/6 "2017-07-05T23:48:04Z")

</div>


