Skip to content

[ES|QL] _score is always 0 when DSL filter is being applied #123967

@stratoula

Description

@stratoula

Elasticsearch Version

8.18

Installed Plugins

No response

Java Version

23.0.2

OS Version

22.6.0 Darwin Kernel Version

Problem Description

_score is always 0 when DSL filter is being applied. This is extremely important for kibana as prefiltering is always added.

Steps to Reproduce

Check this:

POST _query/async
{
  "query": "FROM movies METADATA _score | WHERE Title: \"Shakespeare\" | sort _score DESC | KEEP Title, _score",
  "locale": "en",
  "include_ccs_metadata": true,
  "filter": {
    "bool": {
      "must": [],
      "filter": [],
      "should": [],
      "must_not": []
    }
  }
}

This returns:

#! No limit defined, adding default limit of [1000]
{
  "is_running": false,
  "took": 4,
  "is_partial": false,
  "columns": [
    {
      "name": "Title",
      "type": "text"
    },
    {
      "name": "_score",
      "type": "double"
    }
  ],
  "values": [
    [
      "Shakespeare in Love",
      0
    ],
    [
      "Shakespeare in Love",
      0
    ],
    [
      "Shakespeare in Love",
      0
    ]
  ]
}

If I remove the DSL:

POST _query/async
{
  "query": "FROM movies METADATA _score | WHERE Title: \"Shakespeare\" | sort _score DESC | KEEP Title, _score",
  "locale": "en",
  "include_ccs_metadata": true
}
#! No limit defined, adding default limit of [1000]
{
  "is_running": false,
  "took": 4,
  "is_partial": false,
  "columns": [
    {
      "name": "Title",
      "type": "text"
    },
    {
      "name": "_score",
      "type": "double"
    }
  ],
  "values": [
    [
      "Shakespeare in Love",
      7.960540771484375
    ],
    [
      "Shakespeare in Love",
      7.960540771484375
    ],
    [
      "Shakespeare in Love",
      7.960540771484375
    ]
  ]
}

Logs (if relevant)

No response

Metadata

Metadata

Assignees

Labels

:Search Relevance/SearchCatch all for Search Relevance>bugTeam:Search RelevanceMeta label for the Search Relevance team in Elasticsearchpriority:highA label for assessing bug priority to be used by ES engineers

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions