# Elasticsearch returns documents with score 0.0

**URL:** <https://discuss.elastic.co/t/elasticsearch-returns-documents-with-score-0-0/259289>\
**Category:** Elasticsearch\
**Created:** [December 21, 2020, 4:40pm UTC](https://discuss.elastic.co/t/elasticsearch-returns-documents-with-score-0-0/259289 "2020-12-21T16:40:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![haitran](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/haitran/32/81205_2.png) [@haitran](https://discuss.elastic.co/u/haitran)\
**Post date:** [December 21, 2020, 4:40pm UTC](https://discuss.elastic.co/t/elasticsearch-returns-documents-with-score-0-0/259289/1 "2020-12-21T16:40:29Z")

</div>

Please help me to understand the scoring logic.

Configuration:

```auto
PUT /my-index-000001
{
  "mappings": {
    "dynamic": "false",
    "properties": {
      "test": {
        "type": "text",
        "fields": {
          "_ngram": {
            "type": "text",
            "analyzer": "shingle_ngram"
          },
          "substring": {
            "type": "text",
            "analyzer": "substring"
          }
        },
        "analyzer": "standard"
      }
    }
  },
  "settings": {
    "index": {
      "max_ngram_diff": "7",
      "analysis": {
        "filter": {
          "filter_shingle_ngram": {
            "max_shingle_size": "3",
            "min_shingle_size": "2",
            "type": "shingle"
          }
        },
        "analyzer": {
          "substring": {
            "filter": [
              "lowercase"
            ],
            "char_filter": [
              "html_strip"
            ],
            "tokenizer": "substring_tokenizer"
          },
          "shingle_ngram": {
            "filter": [
              "lowercase",
              "filter_shingle_ngram"
            ],
            "char_filter": [
              "html_strip"
            ],
            "tokenizer": "letter"
          }
        },
        "tokenizer": {
          "substring_tokenizer": {
            "token_chars": [
              "letter",
              "digit"
            ],
            "min_gram": "3",
            "type": "ngram",
            "max_gram": "10"
          }
        }
      }
    }
  }
}

POST my-index-000001/_doc/
{"test": "a"}
POST my-index-000001/_doc/
{"test": "ab"}
POST my-index-000001/_doc/
{"test": "abc"}
POST my-index-000001/_doc/
{"test": "abcd"}

```

Queries:  
Req 1:

```auto
GET my-index-000001/_search
{
  "query": {
    "multi_match": {
      "query": "a",
      "fuzziness": "2",
      "fields": [
        "test",
        "test._ngram",
        "test.substring"
      ],
      "type": "most_fields"
    }
  }
}

```

Res 1:

```auto
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : 2.4079456,
    "hits" : [
      {
        "_index" : "my-index-000001",
        "_type" : "_doc",
        "_id" : "FJwlhnYBhCacSfAqwGxk",
        "_score" : 2.4079456,
        "_source" : {
          "test" : "a"
        }
      },
      {
        "_index" : "my-index-000001",
        "_type" : "_doc",
        "_id" : "FZwlhnYBhCacSfAqxmwj",
        "_score" : 0.0,
        "_source" : {
          "test" : "ab"
        }
      },
      {
        "_index" : "my-index-000001",
        "_type" : "_doc",
        "_id" : "FpwlhnYBhCacSfAqymxv",
        "_score" : 0.0,
        "_source" : {
          "test" : "abc"
        }
      }
    ]
  }
}

```

Req 2:

```auto
GET my-index-000001/_search
{
  "query": {
    "multi_match": {
      "query": "abcd",
      "fuzziness": "2",
      "fields": [
        "test",
        "test._ngram",
        "test.substring"
      ],
      "type": "most_fields"
    }
  }
}

```

Res 2:

```auto
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : 3.3665671,
    "hits" : [
      {
        "_index" : "my-index-000001",
        "_type" : "_doc",
        "_id" : "F5wlhnYBhCacSfAqzmzY",
        "_score" : 3.3665671,
        "_source" : {
          "test" : "abcd"
        }
      },
      {
        "_index" : "my-index-000001",
        "_type" : "_doc",
        "_id" : "FpwlhnYBhCacSfAqymxv",
        "_score" : 2.0637054,
        "_source" : {
          "test" : "abc"
        }
      },
      {
        "_index" : "my-index-000001",
        "_type" : "_doc",
        "_id" : "FZwlhnYBhCacSfAqxmwj",
        "_score" : 0.0,
        "_source" : {
          "test" : "ab"
        }
      }
    ]
  }
}

```

I failed to understand why 0-scored documents are returned.

EDIT 1:  
To clarify, with `"fuzziness": "2"`, those docs should be returned.

---

<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:** [January 18, 2021, 4:40pm UTC](https://discuss.elastic.co/t/elasticsearch-returns-documents-with-score-0-0/259289/2 "2021-01-18T16:40:42Z")

</div>

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