Does specifying the order makes a performance difference for term aggregation?


(Daniel) #1

Hello there.

I am aware that ascending sort order is not accurate for term aggregation, but that is not what I want to discuss now.

By default on term aggregation, buckets are sorted descending by doc_count. I have a function that will specify ascending or descending sort. In order to keep the code smaller, I can just always specify the order and just change a small part of the query based on the order (asc,desc).
However, I am curious if not specifying the sort order at all, and thus falling back to the default descending order could have an impact on performance. Will it be better ? will ti be worse ?

My query is a very simple term count of one single field

    "aggregations": {
      "eventsPerSpace": {
        "terms": {
          shard_size: 200,
          "field": "activeClassroom.keyword",
          "size": 10,
          order: { _count: sort }
        }
      }
    }

Thanks in advance.


(system) closed #2

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