Index pattern management - use new es client instead of legacy (#95293)

* use new es client instead of legacy

* use resolve api on client
This commit is contained in:
Matthew Kime 2021-03-25 14:59:14 -05:00 committed by GitHub
parent dd10c8b5f2
commit 306a42c03c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,19 +31,11 @@ export function registerResolveIndexRoute(router: IRouter): void {
},
},
async (context, req, res) => {
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.indices.resolveIndex({
name: req.params.query,
expand_wildcards: req.query.expand_wildcards || 'open',
});
return res.ok({ body });
}
);
}