# HG changeset patch # Parent 6b7f257e5de8889a4db58463eb93de2befb9694d Allow using SQL search operators "_" and "%" in searches "_" for one character (included in \w, so not listed) "%" for zero or more characters This is only a quick&dirty solution that works when not using Xapian and using an RDBMS that implements INTERSECT, e.g. PostgreSQL or SQLite. http://issues.roundup-tracker.org/issue2550771 (Allow to find substring matches for all text search) diff -r 6b7f257e5de8 roundup/backends/indexer_rdbms.py --- a/roundup/backends/indexer_rdbms.py Thu Aug 13 14:45:53 2015 +1000 +++ b/roundup/backends/indexer_rdbms.py Wed Jan 06 13:32:14 2016 +0100 @@ -94,7 +94,10 @@ if self.db.implements_intersect: # simple AND search - sql = 'select distinct(_textid) from __words where _word=%s'%self.db.arg + if '_' in word or '%' in word: + sql = 'select distinct(_textid) from __words where _word LIKE %s'%self.db.arg + else: + sql = 'select distinct(_textid) from __words where _word=%s'%self.db.arg sql = '\nINTERSECT\n'.join([sql]*len(l)) self.db.cursor.execute(sql, tuple(l)) r = self.db.cursor.fetchall() diff -r 6b7f257e5de8 roundup/cgi/actions.py --- a/roundup/cgi/actions.py Thu Aug 13 14:45:53 2015 +1000 +++ b/roundup/cgi/actions.py Wed Jan 06 13:32:14 2016 +0100 @@ -1055,7 +1055,7 @@ # full-text search if request.search_text: matches = self.db.indexer.search( - re.findall(r'\b\w{2,25}\b', request.search_text), klass) + re.findall(r'[\w%]{2,25}', request.search_text), klass) else: matches = None diff -r 6b7f257e5de8 roundup/cgi/templating.py --- a/roundup/cgi/templating.py Thu Aug 13 14:45:53 2015 +1000 +++ b/roundup/cgi/templating.py Wed Jan 06 13:32:14 2016 +0100 @@ -2781,7 +2781,7 @@ if self.search_text: matches = self.client.db.indexer.search( [w.upper().encode("utf-8", "replace") for w in re.findall( - r'(?u)\b\w{2,25}\b', + r'(?u)[\w%]{2,25}', unicode(self.search_text, "utf-8", "replace") )], klass) else: