# HG changeset patch # User Marcin Kuzminski # Date 2017-04-21 11:34:40 # Node ID 21d2623dfb3f029c8f5594b01425129e0420cf06 # Parent b17a8f3c11975a87037dde6477eb4e2e796bc867 search: added basic example query block. diff --git a/rhodecode/controllers/search.py b/rhodecode/controllers/search.py --- a/rhodecode/controllers/search.py +++ b/rhodecode/controllers/search.py @@ -107,5 +107,6 @@ class SearchController(BaseRepoControlle c.runtime = execution_time c.cur_query = search_query c.search_type = search_type + c.searcher = searcher # Return a rendered template return render('/search/search.mako') diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -1842,6 +1842,24 @@ def journal_filter_help(): ) +def search_filter_help(searcher): + + terms = '' + return _( + 'Example filter terms for `{searcher}` search:\n' + + '{terms}\n' + + 'Generate wildcards using \'*\' character:\n' + + ' "repo_name:vcs*" - search everything starting with \'vcs\'\n' + + ' "repo_name:*vcs*" - search for repository containing \'vcs\'\n' + + '\n' + + 'Optional AND / OR operators in queries\n' + + ' "repo_name:vcs OR repo_name:test"\n' + + ' "owner:test AND repo_name:test*"\n' + + 'More: {search_doc}' + ).format(searcher=searcher.name, + terms=terms, search_doc=searcher.query_lang_doc) + + def not_mapped_error(repo_name): flash(_('%s repository is not mapped to db perhaps' ' it was created or renamed from the filesystem' diff --git a/rhodecode/lib/index/__init__.py b/rhodecode/lib/index/__init__.py --- a/rhodecode/lib/index/__init__.py +++ b/rhodecode/lib/index/__init__.py @@ -33,6 +33,8 @@ default_location = '%(here)s/data/index' class BaseSearch(object): + query_lang_doc = '' + def __init__(self): pass diff --git a/rhodecode/lib/index/whoosh.py b/rhodecode/lib/index/whoosh.py --- a/rhodecode/lib/index/whoosh.py +++ b/rhodecode/lib/index/whoosh.py @@ -61,7 +61,8 @@ log = logging.getLogger(__name__) class Search(BaseSearch): - + # this also shows in UI + query_lang_doc = 'http://whoosh.readthedocs.io/en/latest/querylang.html' name = 'whoosh' def __init__(self, config): diff --git a/rhodecode/templates/search/search.mako b/rhodecode/templates/search/search.mako --- a/rhodecode/templates/search/search.mako +++ b/rhodecode/templates/search/search.mako @@ -63,6 +63,7 @@ ${h.select('type',c.search_type,[('content',_('File contents')), ('commit',_('Commit messages')), ('path',_('File names')),],id='id_search_type')}
+
% for error in c.errors: @@ -71,10 +72,16 @@ % endfor % endfor +
+

${_('Example Queries')}

+ +
+
${c.runtime}
+ ${h.end_form()}