Relates elastic/elasticsearch#787 Original commit: elastic/x-pack-elasticsearch@f0183cedc3
Original commit: elastic/x-pack-elasticsearch@b70f48d25c