diff --git a/src/elasticDSL/Query/Query.ts b/src/elasticDSL/Query/Query.ts index f95c034..e02e48b 100644 --- a/src/elasticDSL/Query/Query.ts +++ b/src/elasticDSL/Query/Query.ts @@ -116,6 +116,9 @@ export function prepareQueryInResolve( if (query.bool) { query.bool = prepareBoolInResolve(query.bool, fieldMap); } + if (query.post_filter) { + query.post_filter = prepareQueryInResolve(query.post_filter, fieldMap); + } if (query.nested && query.nested.query && query.nested.path) { query.nested.path = query.nested.path.replace(/__/g, '.'); query.nested.query = prepareQueryInResolve(query.nested.query, fieldMap); diff --git a/src/elasticDSL/SearchBody.ts b/src/elasticDSL/SearchBody.ts index ce8242b..2a63b7d 100644 --- a/src/elasticDSL/SearchBody.ts +++ b/src/elasticDSL/SearchBody.ts @@ -46,6 +46,9 @@ export function getSearchBodyITC( export function prepareBodyInResolve(body: any, fieldMap: any): { [argName: string]: any } { /* eslint-disable no-param-reassign */ + if (body.post_filter) { + body.post_filter = prepareQueryInResolve(body.post_filter, fieldMap); + } if (body.query) { body.query = prepareQueryInResolve(body.query, fieldMap); } diff --git a/src/resolvers/search.ts b/src/resolvers/search.ts index 04d5d67..5c9212a 100644 --- a/src/resolvers/search.ts +++ b/src/resolvers/search.ts @@ -68,6 +68,7 @@ export default function createSearchResolver( argsConfigMap.sort = searchITC.getField('sort'); argsConfigMap.collapse = searchITC.getField('collapse'); argsConfigMap.highlight = searchITC.getField('highlight'); + argsConfigMap.post_filter = searchITC.getField('post_filter'); const topLevelArgs = [ 'q', @@ -79,6 +80,7 @@ export default function createSearchResolver( 'aggs', 'highlight', 'opts', + 'post_filter', ]; argsConfigMap.opts = schemaComposer .createInputTC({ @@ -157,6 +159,11 @@ export default function createSearchResolver( delete args.query; } + if (args.post_filter) { + args.body.post_filter = args.post_filter; + delete args.post_filter; + } + if (args.collapse) { args.body.collapse = args.collapse; delete args.collapse;