diff --git a/themis/search/indexer.py b/themis/search/indexer.py index 15bc32f..25d0ec7 100644 --- a/themis/search/indexer.py +++ b/themis/search/indexer.py @@ -196,18 +196,25 @@ def contactFuzzyIndexer(obj): v = getattr(obj, attr) if not v: continue - v = v[0] - if ':' in v: - src = ContactsSource() - try: - r = src.fastGetTitleByToken(obj, v) - except KeyError: - return v.split(':')[1:] - if not type(r) is unicode: - r = unicode(r, 'utf-8') - return r - else: - return v + + # it may happen there are several items, merge all of them into a + # single value + result = [] + for contact in v: + if ':' in contact: + src = ContactsSource() + try: + r = src.fastGetTitleByToken(obj, contact) + except KeyError: + result.append(contact.split(':')[1:]) + continue + if not type(r) is unicode: + r = unicode(r, 'utf-8') + result.append(r) + else: + result.append(contact) + if result: + return u' '.join(result) return None grok.global_adapter(contactFuzzyIndexer, name="mailContactFuzzy")