Terms aggs: only use ordinals on low-cardinality fields by default.

Close #5303
Fix sorting of NaN values in terms aggregations.

Closes #5236.
Added unit tests for terms and histogram sorting on sub aggregations that return NaN.
Fix NPE/AIOOBE when building a bucket which has not been collected.

Close #5048
Fix `metric` impl on unmapped fields.
Rewrite BytesStreamOutput on top of BigArrays/ByteArray.

Fix for #5159
check for null term in PagedBytesEstimator.bytesPerValue()

Fixes #5326
Implement custom circuit breaker estimator for parent/child field data
Close Directory / Store once all resources have been released

Currently we close the store and therefor the underlying directory
when the engine / shard is closed ie. during relocation etc. We also
just close it while there are still searches going on and/or we are
recovering from it. The recoveries might fail which is ok but searches
etc. will be working like pending fetch phases.

The contract of the Directory doesn't prevent to read from a stream
that was already opened before the Directory was closed but from a
system boundary perspective and from lifecycles that we test it seems
to be the right thing to do to wait until all resources are released.

Additionally it will also help to make sure everything is closed
properly before directories are closed itself.

Note: this commit adds Object#wait & Object@#notify/All to forbidden APIs
MockRepository shouldn't continue read operation after a simulated failure
[TEST] Add random initial index creation without errors to testRandomDirectoryIOExceptions test

If index was originally created without errors we need to check that index is still not broken after trying to refresh with error. However, if index was created with errors we no longer check that it's correct.