Question about nested top_hits aggregation results _score

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

 {
    "mappings": {
        "_doc" : {
            "properties" : {
				"name": { "type" : "keyword" },
                "supplierName": { "type" : "keyword" },				
                "comments" : { 
                    "type" : "nested",
                    "properties" : {
                        "username" : { "type" : "keyword" },
                        "comment" : { "type" : "text" }
                    }
                }
            }
        }
    }
 }
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

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.

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