[sort] added sort kwarg

authorCarine Dengler <carine.dengler@logilab.fr>
changesetc96089898c6a
branchdefault
phasedraft
hiddenno
parent revision#bcb22f63b5fa Added tag debian/0.8.0-2 for changeset f2bd9c9e607f
child revision<not specified>
files modified by this revision
cubicweb_elasticsearch/views.py
# HG changeset patch
# User Carine Dengler <carine.dengler@logilab.fr>
# Date 1582041242 -3600
# Tue Feb 18 16:54:02 2020 +0100
# Node ID c96089898c6ab9d81d0427a2a3e5668049d5d0a5
# Parent bcb22f63b5fa76efa438f8ba7a897cb439094018
[sort] added sort kwarg

diff --git a/cubicweb_elasticsearch/views.py b/cubicweb_elasticsearch/views.py
@@ -42,10 +42,11 @@
1          'creation_date': DateHistogramFacet(field='creation_date', interval='month'),
2      }
3 
4      def __init__(self, query=None,
5                   filters={},
6 +                 sort=(),
7                   doc_types=None,
8                   index=None,
9                   form=None,
10                   track_total_hits=True,
11                   **kwargs):
@@ -58,11 +59,11 @@
12          else:
13              self.form = {}
14          # Count all the hits by default
15          self.track_total_hits = track_total_hits
16          self.extra_kwargs = kwargs
17 -        super(CWFacetedSearch, self).__init__(query, filters)
18 +        super(CWFacetedSearch, self).__init__(query, filters, sort=sort)
19 
20      def search(self):
21          # override methods to add custom pieces
22          s = super(CWFacetedSearch, self).search()
23          return s.extra(track_total_hits=self.track_total_hits)