# Issue with elasticsearch edge\_ngram query

**URL:** <https://discuss.elastic.co/t/issue-with-elasticsearch-edge-ngram-query/230699>\
**Category:** Elasticsearch\
**Created:** [May 1, 2020, 10:54am UTC](https://discuss.elastic.co/t/issue-with-elasticsearch-edge-ngram-query/230699 "2020-05-01T10:54:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sai\_saran](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sai_saran/32/45746_2.png) [@sai\_saran](https://discuss.elastic.co/u/sai_saran)\
**Post date:** [May 1, 2020, 10:54am UTC](https://discuss.elastic.co/t/issue-with-elasticsearch-edge-ngram-query/230699/1 "2020-05-01T10:54:43Z")

</div>

I am using edge-gram to search in Elasticsearch. This is the analyse I used

```auto
    {
      "settings": {
        "analysis": {
          "analyzer": {
            "my_analyzer": {
              "tokenizer": "my_tokenizer",
              "filter": [
                "lowercase"         
                ]
            }
          },
          "tokenizer": {
            "my_tokenizer": {
              "type": "edge_ngram",
              "min_gram": 2,
              "max_gram": 30,
              "token_chars": [
                "letter",
                "digit"
                ]
            }
          }
        }
      },
      "mappings": {
        "properties": {
          "text": {
            "type": "string",
            "analyzer": "my_analyzer"
          }
        }
      }
    }

```

The problem is when I search the lesser relevant terms have higher score then the more relevant terms.  
Search query:

```auto
    {
        "query": {
            "bool": {
                "should": [
                    {
                        "match": {
                            "text": {
                                "query": "demo coffee"
                            }
                        }
                    }
                ]
            }
        }
    }

```

Response:

```auto
    {
      "took": 1,
      "timed_out": false,
      "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
      },
      "hits": {
        "total": {
          "value": 5,
          "relation": "eq"
        },
        "max_score": 3.0498478,
        "hits": [
          {
            "_index": "test",
            "_type": "_doc",
            "_id": "6",
            "_score": 3.0498478,
            "_source": {
              "text": "Filter Coffee"
            }
          },
          {
            "_index": "test",
            "_type": "_doc",
            "_id": "2",
            "_score": 2.4077744,
            "_source": {
              "text": "Demo Tea"
            }
          },
          {
            "_index": "test",
            "_type": "_doc",
            "_id": "1",
            "_score": 2.3014567,
            "_source": {
              "text": "Demo Coffee"
            }
          },
          {
            "_index": "test",
            "_type": "_doc",
            "_id": "4",
            "_score": 1.4384104,
            "_source": {
              "text": "Coffee Day"
            }
          },
          {
            "_index": "test",
            "_type": "_doc",
            "_id": "7",
            "_score": 0.8630463,
            "_source": {
              "text": "Demo"
            }
          }
        ]
      }
    }

```

Why the "demo coffee" is ranked lower then the other results , even though it has exact match ?

---

<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:** [May 29, 2020, 10:54am UTC](https://discuss.elastic.co/t/issue-with-elasticsearch-edge-ngram-query/230699/2 "2020-05-29T10:54:53Z")

</div>

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