# Match Phrase Suffix option, similar to Match Phrase Prefix?

**URL:** <https://discuss.elastic.co/t/match-phrase-suffix-option-similar-to-match-phrase-prefix/69189>\
**Category:** Elasticsearch\
**Created:** [December 15, 2016, 3:57pm UTC](https://discuss.elastic.co/t/match-phrase-suffix-option-similar-to-match-phrase-prefix/69189 "2016-12-15T15:57:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tdicken73](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@tdicken73](https://discuss.elastic.co/u/tdicken73)\
**Post date:** [December 15, 2016, 3:57pm UTC](https://discuss.elastic.co/t/match-phrase-suffix-option-similar-to-match-phrase-prefix/69189/1 "2016-12-15T15:57:04Z")

</div>

Hi all,

I'm looking for a solution where I need to match a query phrase against multiple fields, represented below as companyField1, companyField2, and companyField3.

I currently am using the following query in my Java program:  
QueryBuilders.multiMatchQuery(companyName, "companyField1", "companyField2", "companyField3").type(MatchQueryBuilder.Type.PHRASE\_PREFIX).operator(Operator.AND);

This works very well for company searches like "International Business Machines", "Business Machines", "International Business Mach", but I am also looking for it to match again "national Business Machines". In other words, I'm looking for something like MatchQueryBuilder.Type.PHRASE\_PREFIX but instead of PHRASE\_PREFIX I would like a PHRASE\_SUFFIX field. Is there anything like this possible, since there is no PHRASE\_SUFFIX built into elasticsearch?

Thanks,  
Todd

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 15, 2016, 4:15pm UTC](https://discuss.elastic.co/t/match-phrase-suffix-option-similar-to-match-phrase-prefix/69189/2 "2016-12-15T16:15:11Z")

</div>

The data structures are much more efficient to use in prefix fashion so there isn't a suffix version. There is a reverse token filter but that doesn't really help you here because it only reverses each token and it wouldn't reverse the whole phrase.

I expect you could build a plugin that implemented the right kind of query to be used in combination with the reverse token filter. I guess the question is, how important is this?

---

<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:** [January 12, 2017, 4:15pm UTC](https://discuss.elastic.co/t/match-phrase-suffix-option-similar-to-match-phrase-prefix/69189/3 "2017-01-12T16:15:38Z")

</div>

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