From a1b42cb3037db8c96c19791e37171434827f002c Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 24 Mar 2021 07:43:48 -0500 Subject: [PATCH 1/2] use new es client instead of legacy --- .../server/routes/resolve_index.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/plugins/index_pattern_management/server/routes/resolve_index.ts b/src/plugins/index_pattern_management/server/routes/resolve_index.ts index 851a2578231aa..2115a6e895814 100644 --- a/src/plugins/index_pattern_management/server/routes/resolve_index.ts +++ b/src/plugins/index_pattern_management/server/routes/resolve_index.ts @@ -34,16 +34,13 @@ export function registerResolveIndexRoute(router: IRouter): void { const queryString = req.query.expand_wildcards ? { expand_wildcards: req.query.expand_wildcards } : null; - const result = await context.core.elasticsearch.legacy.client.callAsCurrentUser( - 'transport.request', - { - method: 'GET', - path: `/_resolve/index/${encodeURIComponent(req.params.query)}${ - queryString ? '?' + new URLSearchParams(queryString).toString() : '' - }`, - } - ); - return res.ok({ body: result }); + const { body } = await context.core.elasticsearch.client.asCurrentUser.transport.request({ + method: 'GET', + path: `/_resolve/index/${encodeURIComponent(req.params.query)}${ + queryString ? '?' + new URLSearchParams(queryString).toString() : '' + }`, + }); + return res.ok({ body }); } ); } From 131b9569f04f2a934005d11f47c93de60a056662 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 24 Mar 2021 10:25:35 -0500 Subject: [PATCH 2/2] use resolve api on client --- .../server/routes/resolve_index.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/plugins/index_pattern_management/server/routes/resolve_index.ts b/src/plugins/index_pattern_management/server/routes/resolve_index.ts index 2115a6e895814..22c214f2adee2 100644 --- a/src/plugins/index_pattern_management/server/routes/resolve_index.ts +++ b/src/plugins/index_pattern_management/server/routes/resolve_index.ts @@ -31,14 +31,9 @@ export function registerResolveIndexRoute(router: IRouter): void { }, }, async (context, req, res) => { - const queryString = req.query.expand_wildcards - ? { expand_wildcards: req.query.expand_wildcards } - : null; - const { body } = await context.core.elasticsearch.client.asCurrentUser.transport.request({ - method: 'GET', - path: `/_resolve/index/${encodeURIComponent(req.params.query)}${ - queryString ? '?' + new URLSearchParams(queryString).toString() : '' - }`, + const { body } = await context.core.elasticsearch.client.asCurrentUser.indices.resolveIndex({ + name: req.params.query, + expand_wildcards: req.query.expand_wildcards || 'open', }); return res.ok({ body }); }