# How to make shorter (closer) token match more relevant? (edge\_ngram)

**URL:** <https://discuss.elastic.co/t/how-to-make-shorter-closer-token-match-more-relevant-edge-ngram/248703>\
**Category:** Elasticsearch\
**Created:** [September 15, 2020, 3:21pm UTC](https://discuss.elastic.co/t/how-to-make-shorter-closer-token-match-more-relevant-edge-ngram/248703 "2020-09-15T15:21:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rebelfreq](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rebelfreq](https://discuss.elastic.co/u/rebelfreq)\
**Post date:** [September 15, 2020, 3:21pm UTC](https://discuss.elastic.co/t/how-to-make-shorter-closer-token-match-more-relevant-edge-ngram/248703/1 "2020-09-15T15:21:39Z")

</div>

Hello,

I'm getting very weird results with `edge_ngram` tokenizer I'm using for autocomplete. I'm trying to figure out how to make my results more relevant. I copied the [example](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-edgengram-tokenizer.html) from the elasticsearch documentation.

I have documents with the following descriptions:

- "Apples, raw, without skin"
- "Apples, raw, golden delicious, with skin",
- "APPLEBEE'S, chili"
- "Babyfood, fruit, applesauce, junior"

If i search for `apple`, **"APPLEBEE'S, chili"** will get higher score than **"Apples, raw, without skin"**  
If i search for `apples`, **"Babyfood, fruit, applesauce, junior"** will get higher score than **"Apples, raw, golden delicious, with skin"**

In both cases I would like to have higher score for the more relevant closer/shorter match (ie. `apples` when I search for `apple` or `apples`

My settings are:

```
"settings": {
  "analysis": {
    "analyzer": {
      "autocomplete": {
        "tokenizer": "autocomplete",
        "filter": [
          "lowercase",
          "asciifolding"
        ]
      },
      "autocomplete_search": {
        "tokenizer": "lowercase"
      }
    },
    "tokenizer": {
      "autocomplete": {
        "type": "edge_ngram",
        "min_gram": 2,
        "max_gram": 20,
        "token_chars": [
          "letter"
        ]
      }
    }
  }
},

```

query:

```
"query": {
    "match": {
      "description": {
          "query": "apple", 
          "operator": "and"
        }
    }
  }

```

What do I have to do to get the more relevant results score higher?

Thanks,  
Gabor

---

<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:** [October 13, 2020, 3:21pm UTC](https://discuss.elastic.co/t/how-to-make-shorter-closer-token-match-more-relevant-edge-ngram/248703/2 "2020-10-13T15:21:49Z")

</div>

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