diff --git a/src/collective/solr/mangler.py b/src/collective/solr/mangler.py index 9701d87..1fa9bd1 100644 --- a/src/collective/solr/mangler.py +++ b/src/collective/solr/mangler.py @@ -88,6 +88,26 @@ def mangleSearchableText(value, config): return value +def mangleTitle(value, config): + levenstein_distance = getattr(config, 'levenshtein_distance', 0) + value_parts = [] + base_value_parts = [] + + if not isSimpleSearch(value): + return value + + for term in splitSimpleSearch(value): + (term_value, + term_base_value) = makeSimpleExpressions(term, + levenstein_distance) + value_parts.append(term_value) + base_value_parts.append(term_base_value) + + base_value = ' '.join(base_value_parts) + value = ' '.join(value_parts) + return value + + def mangleQuery(keywords, config, schema): """ translate / mangle query parameters to replace zope specifics with equivalent constructs for solr """ @@ -129,6 +149,9 @@ def mangleQuery(keywords, config, schema): if key == 'SearchableText': keywords[key] = mangleSearchableText(value, config) continue + if key == 'Title': + keywords[key] = mangleTitle(value, config) + continue if key in epi_indexes: path = keywords['%s_parents' % key] = value del keywords[key]