コード例 #1
0
    def clean_queryset(self, queryset):
        """Clean the queryset.

        - Remove aggregations.
        - Remove highlight.
        - Remove sorting options.

        :param queryset:
        :return:
        """
        queryset.aggs = AggsProxy('')
        queryset._highlight = {}
        queryset._sort = ['_score']
        queryset._functional_suggest = True
        return queryset
コード例 #2
0
def _fields_with_empty_submissions(fields, questionnaire_id, search):
    newfields = []
    if fields:
        newsearch = copy.copy(search)
        newsearch.aggs = AggsProxy(newsearch)
        for field in fields:
            field_name = _get_field_name(field, questionnaire_id)
            newsearch.aggs.bucket('by_' + field['code'],
                                  'value_count',
                                  field=field_name)
        result = newsearch.execute()
        for key in result.aggregations:
            if result.aggregations[key].value != result.hits.total:
                field_code = key.replace('by_', '')
                field = next(field for field in fields
                             if field['code'] == field_code)
                newfields.append(field)
    return newfields
コード例 #3
0
 def __init__(self, *args, **kwargs):
     self.aggs = AggsProxy('')
     self._highlight = {}
     self._sort = []