Elasticsearch returns documents with score 0.0

Please help me to understand the scoring logic.

Configuration:

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:

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

Res 1:

{
  "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:

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

Res 2:

{
  "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.

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