From 237e9092445ef9e9c7880e745f3e225772596449 Mon Sep 17 00:00:00 2001 From: Ajmal Sali Date: Wed, 13 Jul 2022 00:15:32 +0530 Subject: [PATCH] feat: update search.ts to support @elastic/elasticsearch for aggregations, took, timed_out (#141) * Update search.ts to support @elastic/elasticsearch @elastic/elasticsearch client returns the aggregations inside res.body, * Update Search.ts - fix for took, timed_out --- src/resolvers/search.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/resolvers/search.ts b/src/resolvers/search.ts index 878d765..04d5d67 100644 --- a/src/resolvers/search.ts +++ b/src/resolvers/search.ts @@ -191,6 +191,15 @@ export default function createSearchResolver( } const res: any = await searchFC.resolve(rp.source, args, rp.context, rp.info); + if (typeof res.aggregations === 'undefined') { + res.aggregations = res.body.aggregations; + } + if (typeof res.took === 'undefined') { + res.took = res.body.took; + } + if (typeof res.timed_out === 'undefined') { + res.timed_out = res.body.timed_out; + } if (typeof res.hits === 'undefined') { res.count = typeof res.body.hits.total?.value === 'number'