# Max\_score is null when collapse field is used

**URL:** <https://discuss.elastic.co/t/max-score-is-null-when-collapse-field-is-used/232216>\
**Category:** Elasticsearch\
**Created:** [May 12, 2020, 11:27am UTC](https://discuss.elastic.co/t/max-score-is-null-when-collapse-field-is-used/232216 "2020-05-12T11:27:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![agutierrezrodriguez](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@agutierrezrodriguez](https://discuss.elastic.co/u/agutierrezrodriguez)\
**Post date:** [May 12, 2020, 11:28am UTC](https://discuss.elastic.co/t/max-score-is-null-when-collapse-field-is-used/232216/1 "2020-05-12T11:28:00Z")

</div>

Hello!

I found a bug calculating `max_score` with a collapse field and with `track_scores` set to true.

How to replicate:  
Elasticsearch 7.6 (tested in official docker container)

```
# Create empty index
PUT /new_index

# Insert some data
POST /new_index/_doc
{
  "name": "test 1", 
  "age": 20
}
POST /new_index/_doc
{
  "name": "test 2", 
  "age": 20
}
POST /new_index/_doc
{
  "name": "test 3",
  "age": 30
}

# Do the query
GET /new_index/_search 
{
  "query": {
    "match": {
      "name": "test"
    }
  }, 
  "collapse": {"field": "age"}, 
  "track_scores": true
}

# Response
{
  "took" : 12,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [
      {
        "_index" : "new_index",
        "_type" : "_doc",
        "_id" : "cZShCHIBA1Cl-N7kRxqL",
        "_score" : 0.13353139,
        "_source" : {
          "name" : "test 1",
          "age" : 20
        },
        "fields" : {
          "age" : [
            20
          ]
        }
      },
      {
        "_index" : "new_index",
        "_type" : "_doc",
        "_id" : "c5ShCHIBA1Cl-N7kkBrH",
        "_score" : 0.13353139,
        "_source" : {
          "name" : "test 3",
          "age" : 30
        },
        "fields" : {
          "age" : [
            30
          ]
        }
      }
    ]
  }
}

```

As you can see, the max\_score is null even with track\_scores in true with a simple query.

Could someone verify this issue to open the issue in github?

Thanks.

## Regards.

Antonio.

---

<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:** [June 9, 2020, 11:28am UTC](https://discuss.elastic.co/t/max-score-is-null-when-collapse-field-is-used/232216/2 "2020-06-09T11:28:01Z")

</div>

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