Fix search aggs

This commit is contained in:
Kuroshini 2019-11-29 18:31:10 +03:00
parent 4e3a990ac6
commit 530b7e2ab6

View File

@ -58,12 +58,14 @@ class CustomFacetedSearchFilterBackend(FacetedSearchFilterBackend):
qs.query = queryset.query._clone()
filterer = makefilter(__facet)
for param_type in ['must', 'must_not', 'should']:
qs.query._proxied._params[param_type] = list(
filter(
filterer, qs.query._proxied._params[param_type]
if qs.query._proxied._params.get(param_type):
qs.query._proxied._params[param_type] = list(
filter(
filterer, qs.query._proxied._params[param_type]
)
)
)
if not len(qs.query._proxied._params['should']) \
sh = qs.query._proxied._params.get('should')
if (not sh or not len(sh)) \
and qs.query._proxied._params.get('minimum_should_match'):
qs.query._proxied._params.pop('minimum_should_match')
facet_name = '_filter_' + __field