# "Starts With" and Synonyms

**URL:** <https://discuss.elastic.co/t/starts-with-and-synonyms/20522>\
**Category:** Elasticsearch\
**Created:** [October 31, 2014, 7:05pm UTC](https://discuss.elastic.co/t/starts-with-and-synonyms/20522 "2014-10-31T19:05:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lt\_carey\_mahoney](https://avatars.discourse-cdn.com/v4/letter/l/9d8465/32.png) [@lt\_carey\_mahoney](https://discuss.elastic.co/u/lt_carey_mahoney)\
**Post date:** [October 31, 2014, 7:05pm UTC](https://discuss.elastic.co/t/starts-with-and-synonyms/20522/1 "2014-10-31T19:05:34Z")

</div>

Hi,

I am currently working on a "starts with" (mutiple words) functionnality on  
an existing index which analysis is amongst other things based on synonym  
token filter.

Since reindexing is not a problem, my first attempt was to use a approach  
based on a keyword tokenizer. It did the trick, except that synonym token  
filter did not apply (which I understand).

So I had a second attempt using match phrase. Synonym part was correct,  
words order was correct but I did not have the "starts with" anymore.

I am thinking of handling synonym part before indexing, which would be find  
for me but I wonder if there is any better way to do this with ES.

Is there anyway to add a "_position_" constraint on my search query?  
Did I miss something?

An example of what I am expecting to make this clearer  
Let's say I have 3 values in my index and _k_ is a synonym for \*bb \*:

1. "aa bb cc"
2. "aa bb dd"
3. "dd aa bb"

searching "aa bb" returns 1 & 2  
searching "aa k" returns 1 & 2

Thanks,  
Carey

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/59f57c4e-e060-49da-8e2e-6e24b888cbe0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/59f57c4e-e060-49da-8e2e-6e24b888cbe0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:52am UTC](https://discuss.elastic.co/t/starts-with-and-synonyms/20522/2 "2017-07-06T00:52:46Z")

</div>

Closed on July 6, 2017, 12:52am UTC


