diff options
author | Bruno Wagner <bwagner@thoughtworks.com> | 2014-10-16 11:53:56 +0200 |
---|---|---|
committer | Bruno Wagner <bwagner@thoughtworks.com> | 2014-10-16 11:53:56 +0200 |
commit | eacd5fd5f7f47791ddc2e5568b8e4622420d8562 (patch) | |
tree | f303e7593c8eec8cc626b0df489b7e81128ca6dd /service/pixelated/adapter | |
parent | 693957054255b1807ae9c09478a06e191114b7fb (diff) |
#96 Mail searches are now paginated, the pages number start at 1 now
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r-- | service/pixelated/adapter/search.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/service/pixelated/adapter/search.py b/service/pixelated/adapter/search.py index 72e714e9..6b579d87 100644 --- a/service/pixelated/adapter/search.py +++ b/service/pixelated/adapter/search.py @@ -116,16 +116,17 @@ class SearchEngine(object): results = searcher.search(query, **options) return results - def search(self, query): - options = {'limit': 100} + def search(self, query, window, page): + page = int(page) if (page is not None and int(page) > 0) else 1 + window = int(window) or 25 query = query.replace('\"', '') query = query.replace('-in:', 'AND NOT tag:') query = query.replace('in:all', '*') with self._index.searcher() as searcher: - query = QueryParser('body', self._index.schema).parse(query) - results = searcher.search(query, **options) + query = QueryParser('raw', self._index.schema).parse(query) + results = searcher.search_page(query, page, pagelen=window) return [mail['ident'] for mail in results] def remove_from_index(self, mail_id): |