forked from zaclys/searxng
[enh] always enable inner autocompletition (server side only)
This commit is contained in:
parent
516ea9b769
commit
78081baa8f
|
@ -429,34 +429,29 @@ def autocompleter():
|
||||||
# run autocompleter
|
# run autocompleter
|
||||||
completer = autocomplete_backends.get(request.cookies.get('autocomplete'))
|
completer = autocomplete_backends.get(request.cookies.get('autocomplete'))
|
||||||
|
|
||||||
# check if valid autocompleter is selected
|
|
||||||
if not completer:
|
|
||||||
return '', 400
|
|
||||||
|
|
||||||
# parse searx specific autocompleter results like !bang
|
# parse searx specific autocompleter results like !bang
|
||||||
raw_results = searx_bang(query)
|
raw_results = searx_bang(query)
|
||||||
|
|
||||||
# normal autocompletion results only appear if max 3. searx results returned
|
# normal autocompletion results only appear if max 3 inner results returned
|
||||||
if len(raw_results) <= 3:
|
if len(raw_results) <= 3 and completer:
|
||||||
# run autocompletion
|
# run autocompletion
|
||||||
raw_results.extend(completer(query.getSearchQuery()))
|
raw_results.extend(completer(query.getSearchQuery()))
|
||||||
|
|
||||||
# parse results (write :language and !engine back to result string)
|
# parse results (write :language and !engine back to result string)
|
||||||
results = []
|
results = []
|
||||||
for result in raw_results:
|
for result in raw_results:
|
||||||
result_query = query
|
query.changeSearchQuery(result)
|
||||||
result_query.changeSearchQuery(result)
|
|
||||||
|
|
||||||
# add parsed result
|
# add parsed result
|
||||||
results.append(result_query.getFullQuery())
|
results.append(query.getFullQuery())
|
||||||
|
|
||||||
# return autocompleter results
|
# return autocompleter results
|
||||||
if request_data.get('format') == 'x-suggestions':
|
if request_data.get('format') == 'x-suggestions':
|
||||||
return Response(json.dumps([query.query, results]),
|
return Response(json.dumps([query.query, results]),
|
||||||
mimetype='application/json')
|
mimetype='application/json')
|
||||||
else:
|
|
||||||
return Response(json.dumps(results),
|
return Response(json.dumps(results),
|
||||||
mimetype='application/json')
|
mimetype='application/json')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/preferences', methods=['GET', 'POST'])
|
@app.route('/preferences', methods=['GET', 'POST'])
|
||||||
|
|
Loading…
Reference in New Issue