Porter stem applying stemmer

Porter stem gives the result below.

Keyword:

1. hospital
2. hospitality

in _analyze

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

an getting the result as below

{
    "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.

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

Hello,

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

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.

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.

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

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.

can I use the kstem instead of porter_stem

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