# Keywords with spaces and root word stemming

**URL:** https://discuss.elastic.co/t/keywords-with-spaces-and-root-word-stemming/56652
**Category:** Elasticsearch
**Created:** [July 28, 2016, 4:00pm UTC](https://discuss.elastic.co/t/keywords-with-spaces-and-root-word-stemming/56652 "2016-07-28T16:00:13Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![wmjb](https://avatars.discourse-cdn.com/v4/letter/w/76d3ee/32.png) [@wmjb](https://discuss.elastic.co/u/wmjb)
#### Post date: [July 28, 2016, 4:00pm UTC](https://discuss.elastic.co/t/keywords-with-spaces-and-root-word-stemming/56652/1 "2016-07-28T16:00:13Z")

</div>

Hi, I have a data set where you have keywords such as

R1 - Hiking  
R2 - Mountain climbing  
R3 - Hike mountain  
R4 - Climbing rocks  
R5 - Climbing

Now what I'm trying to do is, when user search for something like "climb" ES should match the record with climb key word only (R5). So the basic idea is I should get able to break the words in side the keyword down to it's root word and compare. So if user search for " mountain climb", "mountain climbing", "climb mountains" then ES only return  
R2 record.

I can use English analyzer with stemming but then when user search above query it also returns unwanted results as well. For example.. if the users search for "climb" or "climbing" normally ES returns the R4 and R5 .. but I want ES to return is only R5...

Does anyone know how to accomplish this...

Thanks.....

---

<div class="post-metadata">

### Author: ![DiscussBuster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/discussbuster/32/11042_2.png) [@DiscussBuster](https://discuss.elastic.co/u/DiscussBuster)
#### Post date: [July 29, 2016, 5:54am UTC](https://discuss.elastic.co/t/keywords-with-spaces-and-root-word-stemming/56652/2 "2016-07-29T05:54:54Z")

</div>

Maybe [match phrase query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html#query-dsl-match-query-phrase) would be worth exploring.

---

<div class="post-metadata">

### Author: ![wmjb](https://avatars.discourse-cdn.com/v4/letter/w/76d3ee/32.png) [@wmjb](https://discuss.elastic.co/u/wmjb)
#### Post date: [July 29, 2016, 12:58pm UTC](https://discuss.elastic.co/t/keywords-with-spaces-and-root-word-stemming/56652/3 "2016-07-29T12:58:39Z")

</div>

Hi, Thanks for the suggestion. But I couldn't find a way to solve my issue by using match phrase query.  
I could use keywords but then I cant use stemming feature to compare root words. For an example with keywords, when user search for "climbing" ES will return R5.. But if user search for "climb" it wont return R5 as a result. Same way search query "climbing rocks" will return R4 as the result, but "climb rocks", "climb rocks" wont return any results.

I want to fix that issue and I'm kind of stuck at the moment.

Any suggestions?

---

<div class="post-metadata">

### Author: ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)
#### Post date: [July 29, 2016, 1:29pm UTC](https://discuss.elastic.co/t/keywords-with-spaces-and-root-word-stemming/56652/4 "2016-07-29T13:29:04Z")

</div>

What you're describing is not available out of the box in Elasticsearch. As far as I understand your problem, the analysis chain first needs to tokenize, then stem, then finally put all the tokens back together into one token. This seems to be a rare use case which you would need to write your own TokeFilter for. After a quick search I found a [Concatenate Plugin](https://github.com/francesconero/elasticsearch-concatenate-token-filter) which might be doing what you want, however it doesn't seem to be very actively supported at the moment.

---

<div class="post-metadata">

### Author: ![wmjb](https://avatars.discourse-cdn.com/v4/letter/w/76d3ee/32.png) [@wmjb](https://discuss.elastic.co/u/wmjb)
#### Post date: [July 29, 2016, 1:36pm UTC](https://discuss.elastic.co/t/keywords-with-spaces-and-root-word-stemming/56652/5 "2016-07-29T13:36:54Z")

</div>

Thanks for the reply and the suggestion. Concatenate token filter.. good idea. Let me do some research on that.

---

<div class="post-metadata">

### Author: ![wmjb](https://avatars.discourse-cdn.com/v4/letter/w/76d3ee/32.png) [@wmjb](https://discuss.elastic.co/u/wmjb)
#### Post date: [August 1, 2016, 1:49pm UTC](https://discuss.elastic.co/t/keywords-with-spaces-and-root-word-stemming/56652/6 "2016-08-01T13:49:20Z")

</div>

Excellent suggestion... this worked like a charm.

Thanks a lot

---

<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:31pm UTC](https://discuss.elastic.co/t/keywords-with-spaces-and-root-word-stemming/56652/7 "2017-07-05T22:31:10Z")

</div>


