Releasable XContentBuilder
make the builder releasable (auto closeable), and use it in shards state
also make XContentParser releasable (AutoCloseable) and not closeable since it doesn't throw an IOException
closes #6869
[AGGS] Pass current docid being processed to scripts.

Scripts may internally cache based on docid (as expressions do). This
change makes numeric aggregations using scripts pass the docid when
it changes.
Store: Only send shard exists requests if shards exist locally on disk and are not allocated on that node according to the cluster state.

Closes #6870
[Infra] re-send failed shard messages when receiving a cluster state that still refers to them

In rare cases we may fail to send a shard failure event to the master, or there is no known master when the shard has failed (ex. a couple of node leave the cluster canceling recoveries and causing a master to step down at the same time). When that happens and a cluster state arrives from the (new) master we should resend the shard failure in order for the master to remove the shard from this node.

Closes #6881
[Recovery] don't start a gateway recovery if source node is not found

Due to change introduced in #6825, we now start a local gateway recovery for replicas, if the source node can not be found. The recovery then fails because we never recover replicas from disk.

Closes #6879
[TESTS] Stabilize DisabledFieldDataFormatTests by setting number_of_replicas to 0.
[DOCS] : Indexed scripts/templates

These are the docs for the indexed scripts/templates feature.
Also moved the namespace for the REST endpoints.

Closes #6851
[DOCS][FIX] Fix doc parsing, broken closing block
[DOCS][FIX] Fix reference check in indexed scripts/templates doc.
Aggregations: Fixed Histogram key_as_string bug

The key as string field in the response for the histogram aggregation will now only show if format is specified on the request.

Closes #6655
[TEST] Verify if clear cache request went to all shards.
[DOCS] Move benchmark API to 1.4
Threadpool Info: Allow to serialize negative thread pool sizes

As a SizeValue is used for serializing the thread pool size, a negative number
resulted in throwing an exception when deserializing (using -ea an assertionerror
was thrown).

This fixes a check for changing the serialization logic, so that negative numbers are read correctly, by adding an internal UNBOUNDED value.

Closes #6325
Closes #5357
Add read/write lock semantics to KeyedLock
[FIELDDATA] Use KeyedLock in IndexFieldDataService

Today we synchronize when updating the IndexFieldDataService
datastructures. This might unnecessarily block progress if multiple
request need different fielddata instance for different fields.

This commit also fixes clear calls to actually consistently clear
the caches in the case of an exception.

Closes #6855
REST: Renamed indexed_script and indexed_template specs

The file name of the REST specs should be the same as
the endpoint which it documents.
REST: Fixed indexed script/template tests

The clients don't have access to the error message
for matching purposes.  Rewritten tests to work
with the clients
Serialization: Fix bwc issue by falling back to old threadpool serialization

This fixes an issue introduced by the serialization changes in #6486
which are not needed at all. Node that the serialization itself is not broken
but the TransportClient uses its own version on initial connect and getting
the NodeInfos.
[BUILD] Randomization script refactoring

1) Refactored randomization logic to the top
2) Add logics to support window platforms
Search: Added support for named filters/queries inside nested filters and queries.

Closes #6293