# Search for compounded words

**URL:** <https://discuss.elastic.co/t/search-for-compounded-words/39655>\
**Category:** Elasticsearch\
**Created:** [January 20, 2016, 12:44pm UTC](https://discuss.elastic.co/t/search-for-compounded-words/39655 "2016-01-20T12:44:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kresimirus](https://avatars.discourse-cdn.com/v4/letter/k/cdc98d/32.png) [@kresimirus](https://discuss.elastic.co/u/kresimirus)\
**Post date:** [January 20, 2016, 12:44pm UTC](https://discuss.elastic.co/t/search-for-compounded-words/39655/1 "2016-01-20T12:44:28Z")

</div>

If I use [Compounded Word Token Filter](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-compound-word-tokenfilter.html) for search term "shoerack" I get ["shoerack", "shoe", "rack"] all with the same position in token stream. Because of that search query is created with OR operator between words - as ("shoerack" OR "shoe" OR "rack"). What I need is only ("shoe" AND "rack").

I believe that only way to achieve this is to have Compounded Word Token Filter that:

- Doesn't output original word (in my case it would output only ["shoe", "rack"])

- Increases position for every word created by compounding (in my case it would output only ["shoe(1)", "rack(2)"].

Is this possible in Elasticsearch? I could not find anything in the documentation.

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [January 21, 2016, 3:55pm UTC](https://discuss.elastic.co/t/search-for-compounded-words/39655/2 "2016-01-21T15:55:05Z")

</div>

Positions should only matter if you are executing a phrase or span query. I  
am assuming your problem is that your query is hitting on content that only  
contains half the terms (only "shoe" or "rack") due to the OR operand.

What type of query are you executing? Is the search term "shoerack"?  
Creating your own query of ("shoe" AND "rack") should work.

Cheers,

Ivan

---

<div class="post-metadata">

**Author:** ![kresimirus](https://avatars.discourse-cdn.com/v4/letter/k/cdc98d/32.png) [@kresimirus](https://discuss.elastic.co/u/kresimirus)\
**Post date:** [January 21, 2016, 9:18pm UTC](https://discuss.elastic.co/t/search-for-compounded-words/39655/3 "2016-01-21T21:18:04Z")

</div>

Hi Ivan,

Yes, my search term is "shoerack" and I want to find all documents that have "shoe" AND "rack" in the text. I could create my own query (of "shoe" AND "rack") but that would require of me to split "shoerack" by building my own custom compounder in my web application. I'm actually dealing with German here and there are many search terms that should be compounded in this way.  
I would rather let Elasticsearch to do it since it's probably faster that way (and certainly more convenient).

Cheers,

Kresimir

---

<div class="post-metadata">

**Author:** ![Bart\_Kooijman](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@Bart\_Kooijman](https://discuss.elastic.co/u/Bart_Kooijman)\
**Post date:** [February 6, 2017, 1:54pm UTC](https://discuss.elastic.co/t/search-for-compounded-words/39655/4 "2017-02-06T13:54:34Z")

</div>

Hello Kresimir,

Did you ever solve this problem in Elasticsearch instead of your web application?

Regards,

Bart.

---

<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, 10:03pm UTC](https://discuss.elastic.co/t/search-for-compounded-words/39655/5 "2017-07-05T22:03:31Z")

</div>


