There is no max_doc_count in Elasticsearch for the reasons described in https://github.com/elastic/elasticsearch/issues/21714.
The workaround in that issue may work as a query in Elasticsearch, but it uses a bucket_selector aggregation which is not yet supported in Kibana (see https://github.com/elastic/kibana/issues/17544).