From ba3fe6aca3588262e76d467ae004d0818c987358 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Wed, 18 Nov 2015 19:01:52 -0200 Subject: Issue #526 - Fixed contacts query input and results to only return matched terms --- service/pixelated/adapter/search/contacts.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'service/pixelated/adapter') diff --git a/service/pixelated/adapter/search/contacts.py b/service/pixelated/adapter/search/contacts.py index 0729e146..d981e0bb 100644 --- a/service/pixelated/adapter/search/contacts.py +++ b/service/pixelated/adapter/search/contacts.py @@ -44,9 +44,13 @@ def search_addresses(searcher, query): results = [] for field in ['to', 'cc', 'bcc', 'sender']: query_parser = QueryParser(field, searcher.schema) - results.append(searcher.search(query_parser.parse("*%s*" % query), - limit=None, - mask=restrict_q, - groupedby=sorting.FieldFacet(field, - allow_overlap=True)).groups()) - return flatten(results) + results.append( + searcher.search( + query_parser.parse("*%s*" % query), + limit=None, + mask=restrict_q, + groupedby=sorting.FieldFacet( + field, + allow_overlap=True), + terms=True).matched_terms()) + return [address[1] for address in flatten(results)] -- cgit v1.2.3