# Porter stem applying stemmer

**URL:** <https://discuss.elastic.co/t/porter-stem-applying-stemmer/358177>\
**Category:** Elasticsearch\
**Created:** [April 25, 2024, 8:18am UTC](https://discuss.elastic.co/t/porter-stem-applying-stemmer/358177 "2024-04-25T08:18:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohan\_T](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Mohan\_T](https://discuss.elastic.co/u/Mohan_T)\
**Post date:** [April 25, 2024, 8:18am UTC](https://discuss.elastic.co/t/porter-stem-applying-stemmer/358177/1 "2024-04-25T08:18:55Z")

</div>

Porter stem gives the result below.

**Keyword:**

**1. hospital**  
**2. hospitality**

in \_analyze

```auto
{
    "tokenizer": "standard",
    "filter": [
        "porter_stem"
    ],
    "text": "hospitality"
}

```

an getting the result as below

```auto
{
    "tokens": [
        {
            "token": "hospit",
            "start_offset": 0,
            "end_offset": 8,
            "type": "<ALPHANUM>",
            "position": 0
        }
    ]
}

```

So both are showing the same result, both should show different results.

while querying if am entering **hospitality** , i should get only the hospitality related results. same as **hospital** hospital related results should.

Guide this to resolve the issue.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 25, 2024, 8:46am UTC](https://discuss.elastic.co/t/porter-stem-applying-stemmer/358177/2 "2024-04-25T08:46:57Z")

</div>

You should not use stemmer if you don't want to have stemming.  
But if you want to be able to do both, you can create a subfield with the stemmer, like `text.stemmer` and then search on both fields `text` and `text.stemmer`.

`hospitality` will match then both fields which means an higher score. So it will be the first on the list. But still `hospital` will come as a result but with a lower rank.

You can look at this demo: [Demo script for "A NoSQL search engine to find..." talk · GitHub](https://gist.github.com/dadoonet/5179ee72ecbf08f12f53d4bda1b76bab)

---

<div class="post-metadata">

**Author:** ![Mohan\_T](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Mohan\_T](https://discuss.elastic.co/u/Mohan_T)\
**Post date:** [April 25, 2024, 9:37am UTC](https://discuss.elastic.co/t/porter-stem-applying-stemmer/358177/3 "2024-04-25T09:37:30Z")

</div>

> [@dadoonet](#):
>
> You should not use stemmer if you don't want to have stemming.

Hello,

Only in the above use case, I don't want to use stemmer.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 25, 2024, 12:22pm UTC](https://discuss.elastic.co/t/porter-stem-applying-stemmer/358177/4 "2024-04-25T12:22:47Z")

</div>

So don't apply a stemmer to your field.

---

<div class="post-metadata">

**Author:** ![Mohan\_T](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Mohan\_T](https://discuss.elastic.co/u/Mohan_T)\
**Post date:** [April 29, 2024, 12:30pm UTC](https://discuss.elastic.co/t/porter-stem-applying-stemmer/358177/5 "2024-04-29T12:30:27Z")

</div>

> [@dadoonet](#):
>
> So don't apply a stemmer to your field.

don't want to apply for the specific word means **hospital** & **hospitality** , not the complete field. guide me with the same.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 29, 2024, 12:46pm UTC](https://discuss.elastic.co/t/porter-stem-applying-stemmer/358177/6 "2024-04-29T12:46:59Z")

</div>

> [@Mohan\_T](#):
>
> So both are showing the same result, both should show different results.

What is the stem you would expect the stemmer to return for these two words?

To me it seems expected that they both return the same stem.

---

<div class="post-metadata">

**Author:** ![Mohan\_T](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Mohan\_T](https://discuss.elastic.co/u/Mohan_T)\
**Post date:** [April 29, 2024, 12:49pm UTC](https://discuss.elastic.co/t/porter-stem-applying-stemmer/358177/7 "2024-04-29T12:49:20Z")

</div>

yes, but if searching for **hospital** or **hospitality** it should not apply the stemmer. only for this specific words stemmer should not apply.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 29, 2024, 1:21pm UTC](https://discuss.elastic.co/t/porter-stem-applying-stemmer/358177/8 "2024-04-29T13:21:40Z")

</div>

If you need a single field to handle this I suspect you may need to change your analyser to handle this or possibly create your own stemmer.

---

<div class="post-metadata">

**Author:** ![Mohan\_T](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@Mohan\_T](https://discuss.elastic.co/u/Mohan_T)\
**Post date:** [May 3, 2024, 6:58am UTC](https://discuss.elastic.co/t/porter-stem-applying-stemmer/358177/9 "2024-05-03T06:58:35Z")

</div>

can I use the **kstem** instead of **porter\_stem**

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 3, 2024, 7:17am UTC](https://discuss.elastic.co/t/porter-stem-applying-stemmer/358177/10 "2024-05-03T07:17:27Z")

</div>

I do not know. Test it and see how it behaves.
