diff options
author | Giovane <giovaneliberato@gmail.com> | 2015-11-03 17:59:07 -0200 |
---|---|---|
committer | Giovane <giovaneliberato@gmail.com> | 2015-11-03 17:59:41 -0200 |
commit | 0f84c6354a116fd53628b23a56c1528c5dd3e8ef (patch) | |
tree | d20846b7b47dd613fffce87ce8a43b686d658819 /service/pixelated | |
parent | af7631369c96d3da54abb4e1cab44ea61151c481 (diff) |
[#508] Making search also work with substrings - pairing w/ @pereiragislene
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/adapter/mailstore/leap_mailstore.py | 2 | ||||
-rw-r--r-- | service/pixelated/adapter/search/__init__.py | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py index 2754c624..519b124a 100644 --- a/service/pixelated/adapter/mailstore/leap_mailstore.py +++ b/service/pixelated/adapter/mailstore/leap_mailstore.py @@ -223,7 +223,7 @@ class LeapMailStore(MailStore): def get_mails(self, mail_ids): deferreds = [] for mail_id in mail_ids: - deferreds.append(self.get_mail(mail_id)) + deferreds.append(self.get_mail(mail_id, include_body=True)) return defer.gatherResults(deferreds, consumeErrors=True) diff --git a/service/pixelated/adapter/search/__init__.py b/service/pixelated/adapter/search/__init__.py index 56ab2255..065dd5e5 100644 --- a/service/pixelated/adapter/search/__init__.py +++ b/service/pixelated/adapter/search/__init__.py @@ -23,7 +23,7 @@ import time from pixelated.adapter.model.status import Status from pixelated.adapter.search.contacts import contacts_suggestions from whoosh.index import FileIndex -from whoosh.fields import Schema, ID, KEYWORD, TEXT, NUMERIC +from whoosh.fields import Schema, ID, KEYWORD, TEXT, NUMERIC, NGRAMWORDS from whoosh.qparser import QueryParser from whoosh.qparser import MultifieldParser from whoosh.writing import AsyncWriter @@ -103,9 +103,9 @@ class SearchEngine(object): to=KEYWORD(stored=False, commas=True), cc=KEYWORD(stored=False, commas=True), bcc=KEYWORD(stored=False, commas=True), - subject=TEXT(stored=False), + subject=NGRAMWORDS(stored=False), date=NUMERIC(stored=False, sortable=True, bits=64, signed=False), - body=TEXT(stored=False), + body=NGRAMWORDS(stored=False), tag=KEYWORD(stored=True, commas=True), flags=KEYWORD(stored=True, commas=True), raw=TEXT(stored=False)) @@ -116,7 +116,7 @@ class SearchEngine(object): def index_mail(self, mail): with AsyncWriter(self._index) as writer: - self._index_mail(writer, mail) + self._index_mail(writer, mail) def _index_mail(self, writer, mail): mdict = mail.as_dict() @@ -197,7 +197,7 @@ class SearchEngine(object): .replace('-in:', 'AND NOT tag:') .replace('in:all', '*') ) - return MultifieldParser(['raw', 'body'], self._index.schema).parse(query) + return MultifieldParser(['body', 'subject', 'raw'], self._index.schema).parse(query) def remove_from_index(self, mail_id): with AsyncWriter(self._index) as writer: |