Skip to content

Commit 237e909

Browse files
authored
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
1 parent 4110a8b commit 237e909

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/resolvers/search.ts

+9
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ export default function createSearchResolver<TSource, TContext>(
191191
}
192192

193193
const res: any = await searchFC.resolve(rp.source, args, rp.context, rp.info);
194+
if (typeof res.aggregations === 'undefined') {
195+
res.aggregations = res.body.aggregations;
196+
}
197+
if (typeof res.took === 'undefined') {
198+
res.took = res.body.took;
199+
}
200+
if (typeof res.timed_out === 'undefined') {
201+
res.timed_out = res.body.timed_out;
202+
}
194203
if (typeof res.hits === 'undefined') {
195204
res.count =
196205
typeof res.body.hits.total?.value === 'number'

0 commit comments

Comments
 (0)