How to boost scoring for whole word hits over substring hits

Hi there,

I'd like to make it so that single-word query results that contain the entire query word by itself get higher scoring over results that contain the query word within another word.

For example in the case I am testing, when I search for 'pet', the result scoring does not seem to differentiate between cases containing 'pet' vs. 'appetite'. I would like to make it so that the phrase 'I have a pet allergy' would always return a higher score then 'I have no appetite'.

My settings look like this:

"settings": {
      "index": {
        "number_of_replicas": 2,
        "max_ngram_diff": 7,
      "analysis": {
        "normalizer": {
          "my_normalizer": {
            "type": "custom",
            "char_filter": [],
            "filter": [
        "char_filter": {
          "my_char_filter": {
            "type": "mapping",
            "mappings": [
              "- => _"
        "analyzer": {
          "my_analyzer": {
            "tokenizer": "standard",
            "char_filter": [
            "filter": [
        "filter": {
          "my_ngram": {
            "type": "ngram",
            "min_gram": 4,
            "max_gram": 9,
            "preserve_original": true

Is this behaviour something that should be set in the index or the query itself?

Thank you in advance for any help!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.