summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/search.py
diff options
context:
space:
mode:
authorBruno Wagner <bwagner@thoughtworks.com>2014-10-16 11:53:56 +0200
committerBruno Wagner <bwagner@thoughtworks.com>2014-10-16 11:53:56 +0200
commiteacd5fd5f7f47791ddc2e5568b8e4622420d8562 (patch)
treef303e7593c8eec8cc626b0df489b7e81128ca6dd /service/pixelated/adapter/search.py
parent693957054255b1807ae9c09478a06e191114b7fb (diff)
#96 Mail searches are now paginated, the pages number start at 1 now
Diffstat (limited to 'service/pixelated/adapter/search.py')
-rw-r--r--service/pixelated/adapter/search.py9
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):