# HG changeset patch # User Daniel Dourvaris # Date 2019-12-12 20:40:34 # Node ID 9b536d100e249e4702dfad3ac7cdf4fc7613e728 # Parent cc0663d26ba9891df1e8cb965fa66090741e4bfb audit-logs: fixed search cases with special chars such as `-`. - Changed Text() field into Keyword() field to disable term analyzer. - Fixes #5575 diff --git a/rhodecode/lib/user_log_filter.py b/rhodecode/lib/user_log_filter.py --- a/rhodecode/lib/user_log_filter.py +++ b/rhodecode/lib/user_log_filter.py @@ -22,7 +22,7 @@ import logging from whoosh.qparser.default import QueryParser, query from whoosh.qparser.dateparse import DateParserPlugin -from whoosh.fields import (TEXT, Schema, DATETIME) +from whoosh.fields import (TEXT, Schema, DATETIME, KEYWORD) from sqlalchemy.sql.expression import or_, and_, not_, func from rhodecode.model.db import UserLog @@ -30,11 +30,12 @@ from rhodecode.lib.utils2 import remove_ # JOURNAL SCHEMA used only to generate queries in journal. We use whoosh # querylang to build sql queries and filter journals -JOURNAL_SCHEMA = Schema( - username=TEXT(), +AUDIT_LOG_SCHEMA = Schema( + username=KEYWORD(), + repository=KEYWORD(), + date=DATETIME(), action=TEXT(), - repository=TEXT(), ip=TEXT(), ) @@ -52,7 +53,7 @@ def user_log_filter(user_log, search_ter log.debug('Initial search term: %r', search_term) qry = None if search_term: - qp = QueryParser('repository', schema=JOURNAL_SCHEMA) + qp = QueryParser('repository', schema=AUDIT_LOG_SCHEMA) qp.add_plugin(DateParserPlugin()) qry = qp.parse(safe_unicode(search_term)) log.debug('Filtering using parsed query %r', qry)