elastic / elasticsearch

Free and Open, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.07k stars 24.52k forks source link

Score differs from explanation details #53158

Open garfberg opened 4 years ago

garfberg commented 4 years ago

Hi,

I am facing a scoring issue with Elasticsearch 7.1.1 where the score of some documents does not matches the value it should be as shown in explanation details. It looks like a rounding/precision issue.

The following document shows the problem (see arrow where values that should be equal):

{
    "_shard": "[idx1][0]",
    "_node": "Mh6oqdT7Qtmj0z-0Cg7Hwg",
    "_index": "idx1",
    "_type": "_doc",
    "_id": "htPMOXABCO_fnakQ4ZcJ",
    "_score": 122.38026,
    "sort": [
        122.38026,
    ],
    "_explanation": {
        "value": 122.38026,                          <-- Looks wrong to me
        "description": "sum of:",
        "details": [
            {
                "value": 122.38025,           <-- This is the expected value
                "description": "sum of",
                "details": [ ...

The search I perform is done on a 1 node cluster, on an alias regrouping 2 indices with 1 shard each.

GET /_cat/aliases/oym_search?v

alias      index                                    filter routing.index routing.search
idx1           -      -             -
idx2           -      -             -

Testing directly on "idx1" containing the document does not reproduce the problem: It gets a score of 122.37806 , but it may be due to the fact the term frequency differs.

Finally, the request performing is a function score query (I removed search terms and score functions for more clarity):

GET oym_search/_search?search_type=dfs_query_then_fetch&explain=true

{
  "from": 0,
  "size": 10,
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "must": [ ...
          ],
          "adjust_pure_negative": true,
          "boost": 1
        }
      },
      "functions": [ ...
      ],
      "score_mode": "sum",
      "boost_mode": "sum",
      "max_boost": 3.4028235e+38,
      "boost": 1
    }

ES Version:

{
  ...
  "cluster_uuid" : "0B1Tep9PTMu8xi5TYvaRsQ",
  "version" : {
    "number" : "7.1.1",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "7a013de",
    "build_date" : "2019-05-23T14:04:00.380842Z",
    "build_snapshot" : false,
    "lucene_version" : "8.0.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

ES Plugins: analysis-icu,analysis-phonetic

JVM:

# java -version
java version "12.0.1" 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)

OS:

# uname -a
Linux rs 4.9.185-xxxx-std-ipv6-64 #799710 SMP Wed Jul 10 08:31:28 UTC 2019 x86_64 GNU/Linux
jimczi commented 4 years ago

@mayya-sharipova can you take a look ?

elasticmachine commented 4 years ago

Pinging @elastic/es-search (:Search/Ranking)

elasticsearchmachine commented 1 year ago

Pinging @elastic/es-search (Team:Search)

elasticsearchmachine commented 1 month ago

Pinging @elastic/es-search-relevance (Team:Search Relevance)