summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2014-03-12 14:13:07 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2014-03-12 14:13:20 (GMT)
commitc81459df504b8ca7dcb286e388256f1ac7977f4f (patch)
tree1fb4e449f9d34222ab3de4e8ffba5909f4e321ce
parent16a42c15b7c57dbf98fea0808867dc419c9507f8 (diff)
downloadcollective.solr-c81459df504b8ca7dcb286e388256f1ac7977f4f.zip
collective.solr-c81459df504b8ca7dcb286e388256f1ac7977f4f.tar.gz
collective.solr-c81459df504b8ca7dcb286e388256f1ac7977f4f.tar.bz2
mangle Title like it's done for SearchableText (#4446)
-rw-r--r--src/collective/solr/mangler.py23
1 files changed, 23 insertions, 0 deletions
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]