Show More
@@ -124,18 +124,25 b' class WhooshSearcher(BaseSearcher):' | |||||
124 | query = qp.parse(safe_unicode(query)) |
|
124 | query = qp.parse(safe_unicode(query)) | |
125 | log.debug('query: %s (%s)', query, repr(query)) |
|
125 | log.debug('query: %s (%s)', query, repr(query)) | |
126 |
|
126 | |||
127 | reverse, sortedby = False, None |
|
127 | def sort_def(_direction, _sort_field): | |
128 | if search_type == 'message': |
|
128 | field2whoosh = { | |
129 | if sort == 'oldfirst': |
|
129 | 'message.raw': 'message', | |
130 |
|
|
130 | 'author.email.raw': 'author', | |
|
131 | } | |||
|
132 | return field2whoosh.get(_sort_field) or _sort_field | |||
|
133 | ||||
|
134 | reverse, sorted_by = False, None | |||
|
135 | direction, sort_field = self.get_sort(search_type, sort) | |||
|
136 | if sort_field: | |||
|
137 | if direction == Searcher.DIRECTION_DESC: | |||
|
138 | reverse = True | |||
|
139 | if direction == Searcher.DIRECTION_ASC: | |||
131 | reverse = False |
|
140 | reverse = False | |
132 | elif sort == 'newfirst': |
|
141 | sorted_by = sort_def(direction, sort_field) | |
133 | sortedby = 'date' |
|
|||
134 | reverse = True |
|
|||
135 |
|
142 | |||
136 | whoosh_results = self.searcher.search( |
|
143 | whoosh_results = self.searcher.search( | |
137 | query, filter=allowed_repos_filter, limit=None, |
|
144 | query, filter=allowed_repos_filter, limit=None, | |
138 | sortedby=sortedby, reverse=reverse) |
|
145 | sortedby=sorted_by, reverse=reverse) | |
139 |
|
146 | |||
140 | # fixes for 32k limit that whoosh uses for highlight |
|
147 | # fixes for 32k limit that whoosh uses for highlight | |
141 | whoosh_results.fragmenter.charlimit = None |
|
148 | whoosh_results.fragmenter.charlimit = None |
General Comments 0
You need to be logged in to leave comments.
Login now