# Question about nested top\_hits aggregation results \_score

**URL:** <https://discuss.elastic.co/t/question-about-nested-top-hits-aggregation-results-score/165376>\
**Category:** Elasticsearch\
**Created:** [January 23, 2019, 10:21am UTC](https://discuss.elastic.co/t/question-about-nested-top-hits-aggregation-results-score/165376 "2019-01-23T10:21:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Slade](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Slade](https://discuss.elastic.co/u/Slade)\
**Post date:** [January 23, 2019, 10:21am UTC](https://discuss.elastic.co/t/question-about-nested-top-hits-aggregation-results-score/165376/1 "2019-01-23T10:21:33Z")

</div>

I'm trying to get nested top\_hits results to receive a score which I can then sort by but it seems that all of the results always have \_score 1

PUT /item

```auto
 {
    "mappings": {
        "_doc" : {
            "properties" : {
				"name": { "type" : "keyword" },
                "supplierName": { "type" : "keyword" },				
                "comments" : { 
                    "type" : "nested",
                    "properties" : {
                        "username" : { "type" : "keyword" },
                        "comment" : { "type" : "text" }
                    }
                }
            }
        }
    }
 }

```

```auto
PUT /item/_doc/3?refresh
{
     "name":"ItemOne",
     "supplierName":"CoolSupplier",
     "comments": [
         
         {"username": "mark", "comment": "Cool item1"},
         {"username": "mark", "comment": "Cool item2"},
         {"username": "mark", "comment": "Cool item3"},
         {"username": "mark", "comment": "Cool item4"},
         {"username": "mark", "comment": "Cool item5"},
         {"username": "mark", "comment": "Cool item6"},
         {"username": "jake", "comment": "Bad item"},
         {"username": "steve", "comment": "Great item"}
     ]
}

```

For example from the query below I'd assume that all hits would have their boost incremented by 1.1 and the comment "Cool item3" to have its score boosted by 2.1. But all hits have a \_score of 1.0

```auto
GET item/_search
{
  "size": 0,
  "aggs": {
    "outerFilter": {
      "filter": {
        "match": {
          "supplierName": "CoolSupplier"
        }
      },
      "aggs": {
        "commentAggs": {
          "nested": {
            "path": "comments"
          },
          "aggs": {
            "commentsFilter": {
              "filter": {
                "bool": {
                  "should": [
                    {
                      "match": {
                        "comments.comment": {
                          "query": "Cool item3",
                          "boost":1
                        }
                      }
                    },
                    {
                      "match_all": {
                          "boost":1.1
                      }
                    }
                  ]
                }
              },
              "aggs": {
                "foundComments": {
                  "top_hits": {
                    "size": 4,
                    "sort": {"_score":"desc"}
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

```

Is there a way to accomplish this using nested top\_hits aggregation or do I need to look elsewhere.  
Thanks in advance.

---

<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:** [February 20, 2019, 10:21am UTC](https://discuss.elastic.co/t/question-about-nested-top-hits-aggregation-results-score/165376/2 "2019-02-20T10:21:41Z")

</div>

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