From 97310b163ab67fa0942cdad6bef2d970efef59c1 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Tue, 12 Feb 2019 13:18:01 +0000 Subject: [PATCH] Remove (to be deprecated) rest_total_hits_as_int parameter Change checkValidNode response parsing Update type --- .../infra/server/lib/adapters/framework/adapter_types.ts | 5 ++++- .../server/lib/adapters/metrics/lib/check_valid_node.ts | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts index 1bbf1b8d8ae8..65af9b5a7a3d 100644 --- a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts @@ -114,7 +114,10 @@ export interface InfraDatabaseSearchResponse }; aggregations?: Aggregations; hits: { - total: number; + total: { + value: number; + relation: string; + }; hits: Hit[]; }; } diff --git a/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts b/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts index c098704f1caa..88847acb2908 100644 --- a/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts +++ b/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts @@ -14,7 +14,6 @@ export const checkValidNode = async ( ): Promise => { const params = { index: indexPattern, - rest_total_hits_as_int: true, terminateAfter: 1, body: { size: 0, @@ -25,5 +24,7 @@ export const checkValidNode = async ( }, }, }; - return (await search(params)).hits.total > 0; + + const result = await search(params); + return result && result.hits && result.hits.total && result.hits.total.value > 0; };