def _paginated_search_mails(self, query, window, page): page = int(page) if page is not None and int(page) > 1 else 1 window = int(window) if window is not None else 25 with self._index.searcher() as searcher: tags_facet = sorting.FieldFacet("tag", allow_overlap=True, maptype=sorting.Count) sorting_facet = sorting.FieldFacet("date", reverse=True) results = searcher.search_page(query, page, pagelen=window, groupedby=tags_facet, sortedby=sorting_facet) return unique([mail["ident"] for mail in results]), sum(results.results.groups().values())
def _index_mail(self, writer, mail): mdict = mail.as_dict() header = mdict['header'] tags = mdict.get('tags', []) tags.append(mail.mailbox_name.lower()) index_data = { 'sender': unicode(header.get('from', '')), 'subject': unicode(header.get('subject', '')), 'date': milliseconds(header.get('date', '')), 'to': unicode(header.get('to', '')), 'cc': unicode(header.get('cc', '')), 'bcc': unicode(header.get('bcc', '')), 'tag': u','.join(unique(tags)), 'body': unicode(mdict['body']), 'ident': unicode(mdict['ident']), 'flags': unicode(','.join(unique(mail.flags))), 'raw': unicode(mail.raw) } writer.update_document(**index_data)
def _index_mail(self, writer, mail): mdict = mail.as_dict() header = mdict['header'] tags = set(mdict.get('tags', {})) tags.add(mail.mailbox_name.lower()) index_data = { 'sender': self._empty_string_to_none(header.get('from', '')), 'subject': self._empty_string_to_none(header.get('subject', '')), 'date': self._format_utc_integer(header.get('date', '')), 'to': self._format_recipient(header, 'to'), 'cc': self._format_recipient(header, 'cc'), 'bcc': self._format_recipient(header, 'bcc'), 'tag': u','.join(unique(tags)), 'body': unicode(mdict['textPlainBody'] if 'textPlainBody' in mdict else mdict['body']), 'ident': unicode(mdict['ident']), 'flags': unicode(','.join(unique(mail.flags))), 'raw': unicode(mail.raw) } writer.update_document(**index_data)
def _index_mail(self, writer, mail): mdict = mail.as_dict() header = mdict["header"] tags = set(mdict.get("tags", {})) tags.add(mail.mailbox_name.lower()) bounced = mail.bounced if mail.bounced else [""] index_data = { "sender": self._empty_string_to_none(header.get("from", "")), "subject": self._empty_string_to_none(header.get("subject", "")), "date": milliseconds(header.get("date", "")), "to": self._format_recipient(header, "to"), "cc": self._format_recipient(header, "cc"), "bcc": self._format_recipient(header, "bcc"), "tag": u",".join(unique(tags)), "bounced": u",".join(bounced), "body": unicode(mdict["textPlainBody"] if "textPlainBody" in mdict else mdict["body"]), "ident": unicode(mdict["ident"]), "flags": unicode(",".join(unique(mail.flags))), "raw": unicode(mail.raw), } writer.update_document(**index_data)
def _index_mail(self, writer, mail): mdict = mail.as_dict() header = mdict['header'] tags = set(mdict.get('tags', {})) tags.add(mail.mailbox_name.lower()) bounced = mail.bounced if mail.bounced else [''] index_data = { 'sender': self._unicode_header_field(header.get('from', '')), 'subject': self._unicode_header_field(header.get('subject', '')), 'date': milliseconds(header.get('date', '')), 'to': self._format_recipient(header, 'to'), 'cc': self._format_recipient(header, 'cc'), 'bcc': self._format_recipient(header, 'bcc'), 'tag': u','.join(unique(tags)), 'bounced': u','.join(bounced), 'body': unicode(mdict['textPlainBody'] if 'textPlainBody' in mdict else mdict['body']), 'ident': unicode(mdict['ident']), 'flags': unicode(','.join(unique(mail.flags))), 'raw': unicode(mail.raw) } writer.update_document(**index_data)
def _index_mail(self, writer, mail): mdict = mail.as_dict() header = mdict['header'] tags = mdict.get('tags', []) tags.append(mail.mailbox_name.lower()) bounced = mail.bounced if mail.bounced else [''] index_data = { 'sender': self._unicode_header_field(header.get('from', '')), 'subject': self._unicode_header_field(header.get('subject', '')), 'date': milliseconds(header.get('date', '')), 'to': u','.join([h.decode('utf-8') for h in header.get('to', [''])]), 'cc': u','.join([h.decode('utf-8') for h in header.get('cc', [''])]), 'bcc': u','.join([h.decode('utf-8') for h in header.get('bcc', [''])]), 'tag': u','.join(unique(tags)), 'bounced': u','.join(bounced), 'body': unicode(mdict['textPlainBody']), 'ident': unicode(mdict['ident']), 'flags': unicode(','.join(unique(mail.flags))), 'raw': unicode(mail.raw.decode('utf-8')) } writer.update_document(**index_data)
def _paginated_search_mails(self, query, window, page): page = int(page) if page is not None and int(page) > 1 else 1 window = int(window) if window is not None else 25 with self._index.searcher() as searcher: tags_facet = sorting.FieldFacet('tag', allow_overlap=True, maptype=sorting.Count) sorting_facet = sorting.FieldFacet('date', reverse=True) results = searcher.search_page(query, page, pagelen=window, groupedby=tags_facet, sortedby=sorting_facet) return unique([mail['ident'] for mail in results ]), sum(results.results.groups().values())
def _search_all_mails(self, query): with self._index.searcher() as searcher: sorting_facet = sorting.FieldFacet("date", reverse=True) results = searcher.search(query, sortedby=sorting_facet, reverse=True, limit=None) return unique([mail["ident"] for mail in results])
def _search_all_mails(self, query): with self._index.searcher() as searcher: sorting_facet = sorting.FieldFacet('date', reverse=True) results = searcher.search(query, sortedby=sorting_facet, reverse=True, limit=None) return unique([mail['ident'] for mail in results])