### Elasticsearch Version

8.8.2

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

MacOS

### Problem Description

Adding the collapse field option

```
  "collapse": {
    "field": "age"
  },
```
to a query results in the max_score being returned as null. This is true even if you set `"track_scores": true`. It is reported that this used to work in older versions of Elasticsearch (v5.3 was the version report where it worked - not sure when it stopped working). 

Fix: The max_score field should be set when a collapse clause is added to a search and `"track_scores": true`.

The [end user docs for collapse](https://www.elastic.co/guide/en/elasticsearch/reference/current/collapse-search-results.html) do not provide any guidance on this issue and do not discuss the `track_scores` setting, so that document should also be updated as part of this ticket.

### Steps to Reproduce

```
# 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
}

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

Result of query shows that hits.max_score is null:

```
{
  "took": 41,
  "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",
        "_id": "2EpIT4kBcNLTHWis0ZCU",
        "_score": 0.13353139,
        "_source": {
          "name": "test 1",
          "age": 20
        },
        "fields": {
          "age": [
            20
          ]
        }
      },
      {
        "_index": "new_index",
        "_id": "2kpIT4kBcNLTHWis3JCu",
        "_score": 0.13353139,
        "_source": {
          "name": "test 3",
          "age": 30
        },
        "fields": {
          "age": [
            30
          ]
        }
      }
    ]
  }
}
```

If you run without the collapse/field entry in the query, the max_score is not null.

### Logs (if relevant)

_No response_
server/src/main/java/org/elasticsearch/search/query/TopDocsCollectorManagerFactory.java
MaxScoreQueryVisitor visitor = new MaxScoreQueryVisitor();
        query.visit(visitor);
        return visitor.hasInfMaxScore;
    }
    private static class MaxScoreQueryVisitor extends QueryVisitor {
        private boolean hasInfMaxScore;
        @Override
        public void visitLeaf(Query query) {
            checkMaxScoreInfo(query);
        }
        @Override
        public QueryVisitor getSubVisitor(BooleanClause.Occur occur, Query parent) {
            if (occur != BooleanClause.Occur.MUST) {
                
                
                return QueryVisitor.EMPTY_VISITOR;
            }
            checkMaxScoreInfo(parent);
            return this;
        }
        void checkMaxScoreInfo(Query query) {
            if (query instanceof FunctionScoreQuery || query instanceof ScriptScoreQuery || query instanceof SpanQuery) {
                hasInfMaxScore = true;
            } else if (query instanceof ESToParentBlockJoinQuery q) {
                hasInfMaxScore |= (q.getScoreMode() != org.apache.lucene.search.join.ScoreMode.None);
            }
        }
    }
}