Seems the check in Search.to_dict for the if count needs to be before it adds the post_filter. In this case the post_filter is on a aggs.bucket which doesn't get added.