# Ends with operator in elastic search

**URL:** <https://discuss.elastic.co/t/ends-with-operator-in-elastic-search/139352>\
**Category:** Elasticsearch\
**Created:** [July 10, 2018, 1:24pm UTC](https://discuss.elastic.co/t/ends-with-operator-in-elastic-search/139352 "2018-07-10T13:24:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivar/32/83691_2.png) [@ivar](https://discuss.elastic.co/u/ivar)\
**Post date:** [July 10, 2018, 1:24pm UTC](https://discuss.elastic.co/t/ends-with-operator-in-elastic-search/139352/1 "2018-07-10T13:24:58Z")

</div>

I'm using elastic search 5.6

is there an ends with operator ?  
is wildcard:"\*suffix" the only option to search for a field ending with suffix ?

---

<div class="post-metadata">

**Author:** ![Varan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varan/32/32120_2.png) [@Varan](https://discuss.elastic.co/u/Varan)\
**Post date:** [July 10, 2018, 2:04pm UTC](https://discuss.elastic.co/t/ends-with-operator-in-elastic-search/139352/2 "2018-07-10T14:04:45Z")

</div>

What's wrong with "\*suffix$" ?

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [July 10, 2018, 9:12pm UTC](https://discuss.elastic.co/t/ends-with-operator-in-elastic-search/139352/3 "2018-07-10T21:12:48Z")

</div>

If frequently searching for text that "ends with", you might want to consider using a custom analyzer that

1. Reverses tokens using [reverse token filter](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-reverse-tokenfilter.html)
2. Use [edgengram token filter](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-edgengram-tokenfilter.html) to generate reversed prefixes
3. Reverse prefixes to get suffixes using reverse token filter

---

<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 7, 2018, 9:12pm UTC](https://discuss.elastic.co/t/ends-with-operator-in-elastic-search/139352/4 "2018-08-07T21:12:59Z")

</div>

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