# How does scoring works?

**URL:** <https://discuss.elastic.co/t/how-does-scoring-works/121230>\
**Category:** Elasticsearch\
**Created:** [February 23, 2018, 2:26pm UTC](https://discuss.elastic.co/t/how-does-scoring-works/121230 "2018-02-23T14:26:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Santiago\_Respane](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@Santiago\_Respane](https://discuss.elastic.co/u/Santiago_Respane)\
**Post date:** [February 23, 2018, 2:26pm UTC](https://discuss.elastic.co/t/how-does-scoring-works/121230/1 "2018-02-23T14:26:30Z")

</div>

Hi guys, i dont seem to understand how does ES scoring works.

I have a three values in a field:  
-Bean  
-Soybean  
-Winged bean.

Why when i perform a wildcard search by _bea_ sorted by score it retrieves the following:

```
  "buckets": [
    {
      "key": "Soybean",
      "doc_count": 28,
      "max_score": {
        "value": 3.7833919525146484
      }
    },
    {
      "key": "Bean",
      "doc_count": 12,
      "max_score": {
        "value": 4.607567310333252
      }
    },
    {
      "key": "Winged bean",
      "doc_count": 3,
      "max_score": {
        "value": 5.880533218383789
      }
    }.....

```

based on levenshtein algorythm, shouldn't be bean closer to _bea_ than Soybean? How does ES scoring works?  
How can i perform a sorting by levenshtein distance?  
is this possible?

Kind regards,

---

<div class="post-metadata">

**Author:** ![shanec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanec/32/4004_2.png) [@shanec](https://discuss.elastic.co/u/shanec)\
**Post date:** [March 2, 2018, 10:29pm UTC](https://discuss.elastic.co/t/how-does-scoring-works/121230/2 "2018-03-02T22:29:18Z")

</div>

Elasticsearch performs scoring/sorting based on [BM25](https://en.wikipedia.org/wiki/Okapi_BM25) by default as of version 5.0. You can use other [scoring models, including scripting your own if you like](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-similarity.html#_available_similarities). You could force sorting by levenshtein distance by using different fixed fuzziness along with constant scores in [fuzzy query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html) blocks, but it wouldn't be very good.

---

<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:** [March 30, 2018, 10:29pm UTC](https://discuss.elastic.co/t/how-does-scoring-works/121230/3 "2018-03-30T22:29:38Z")

</div>

Closed on March 30, 2018, 10:29pm UTC

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