Elasticsearch - sort by two levels in the aggregation list

I'm currently sorting aggregation by document count, so the most relevant items are on the aggregation list, as shown below:

{
            'aggs' : {
                'guilds' : {
                    'terms' : {
                        'field' : 'guilds.title.original',
                        'order' : [{'max_score' : 'desc'}],
                        'aggs' : {
                            'max_score' : {
                                'script' : 'doc.score'
                            }
                        }
                    }
                }
            }
        }

I want to add another sorting option to an order order array in my JSON. but when I do this:

{
        'order' : [{'max_score' : 'desc'}, {"_count" : "desc"},
    }

The second sort does not work. For example, when all points are equal, it should sort on demand, but it does not work.

+4
source share
2 answers

, ... , , : , ElasticSearch 1.5 .

, , : "order" : [ { "max_score": "desc" }, { "_count": "desc" } ]

, ES , , "order".

+7

, , , : "" , "" "" aggs , , aggs "max_score" "" "aggs". , ( ), :

  "aggs": {
    "guilds": {
      "terms": {
        "field": "guilds.title.original",
        "order": {
          "max_score": "desc", 
          "_count": "desc"
        }
      },
      "aggs": {
        "max_score": {
          "max": {
            "script": "doc.score"
          }
        }
      }
    }
  }
+7

All Articles