I using the top hits aggregation with a has_child query. In the top_hits 
aggregation documentation it says '*By default the hits are sorted by the 
score of the main query*', but I'm not seeing that in the results for my 
query

{
  "from": 0,
  "size": 3,
  "query": {
    "has_child": {
      "score_mode": "max",
      "type": "child_type",
      "query": {
        "match": {
          "myField": {
            "query": "some text"
          }
        }
      }
    }
  },
  "aggs": {
    "replies": {
      "terms": {
        "field": "parent_type_id",
        "size": 3
      },
      "aggs": {
        "topChildren": {
          "top_hits": {
            "size": 1
          }
        }
      }
    }
  }
}

the has_child query returns three parent results with the following scores.

   - doc 1 = 0.83619833
   - doc 2 = 0.7210085
   - doc 3 = 0.7210085

The score for the top hits aggregations are:

   - first top hit aggregation = 0.29160267
   - second top hit aggregation  = 0.83619833
   - third top hit aggregation = 0.58320534

So the 'second top hit aggregation' should be returned first followed with 
aggregations with the score  0.7210085?





-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/0b6849ad-4308-4afe-a76b-80153620f74b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to