Word matching (partial and full)

Lets say I have a document indexed to ES with

content: "Tim Cook revealed during the earnings call that iPhone sales in India grew by 56% on a yearly basis, despite the company's first global sales decline in 13 years."
Now if a user searches for a word using a match query

{
  "query": {
    "match": {
      "answer": {
        "query": "decline"
      }
    }
}}

say i get a score of 0.047.

But with the same query, if I search for the word "declining", I get a score of 0. I want to check if the word is partially present in the document or not. How can I do this?

Thanks in advance :slight_smile:

Hi ASN,

Have a look on n-Gram's it should do what you're looking for:

The official documentation:
https://www.elastic.co/guide/en/elasticsearch/guide/current/ngrams-compound-words.html

Good luck!

Thanks Gui.
As far as I understood (I just started with ES), ngram with tokenizer is splitting the word in individual letters. In that case , even if i match for "dec" then the result is shown. I wanted it to be the word match but some adjectives/adverbs added to it.. like "declining","slow->slowly"

Hope I made my point clear.

Oh right, you should be looking at synonyms then:
https://www.elastic.co/guide/en/elasticsearch/guide/current/synonyms.html

Which falls under 'dealing with human language' topic:
https://www.elastic.co/guide/en/elasticsearch/guide/current/languages.html

Good luck! :slight_smile:

Thanks Gui.