From c19b0899a415fa3be7c1f30258c218868ef0b671 Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Sat, 10 Jan 2015 19:55:21 +0100 Subject: [PATCH] [fix] little autocompleter fix --- searx/autocomplete.py | 4 ++-- searx/webapp.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/searx/autocomplete.py b/searx/autocomplete.py index ad509934..7ebebf1d 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -52,7 +52,7 @@ def searx_bang(full_query): # check if query starts with engine name for engine in engines: - if engine.startswith(engine_query): + if engine.startswith(engine_query.replace('_', ' ')): results.append('!{engine}'.format(engine=engine.replace(' ', '_'))) # check if query starts with engine shortcut @@ -86,7 +86,7 @@ def searx_bang(full_query): results.append(':{lang_name}'.format(lang_name=lang_name)) # check if query starts with country - if country.startswith(engine_query): + if country.startswith(engine_query.replace('_', ' ')): results.append(':{country}'.format(country=country.replace(' ', '_'))) # remove duplicates diff --git a/searx/webapp.py b/searx/webapp.py index 3dcba296..bd79e003 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -355,8 +355,10 @@ def autocompleter(): # parse searx specific autocompleter results like !bang raw_results = searx_bang(query) - # run autocompletion - raw_results.extend(completer(query.getSearchQuery())) + # normal autocompletion results only appear if max 3. searx results returned + if len(raw_results) <= 3: + # run autocompletion + raw_results.extend(completer(query.getSearchQuery())) # parse results (write :language and !engine back to result string) results = []