index more words from thesaurus (#4570)

This commit is contained in:
Frédéric Péters 2014-03-25 16:42:05 +01:00
parent dbf6acb98f
commit ca14ea0a5c
1 changed files with 16 additions and 0 deletions

View File

@ -61,6 +61,22 @@ class DmsKeyword(Item):
""" """
implements(IDmsKeyword)
def get_words_for_indexation(self, limit=5):
thesaurus = aq_parent(self)
words = []
words.append(self.title)
for word in self.equivs or []:
words.append(word)
if limit > 0:
for broader_keyword in self.broader or []:
try:
keyword = thesaurus[broader_keyword]
except KeyError:
continue
words.append(keyword.get_words_for_indexation(limit=limit-1))
return ' '.join(words)
class DmsKeywordSchemaPolicy(DexteritySchemaPolicy):
""" """