@@ -6,6 +6,7 @@ from urllib.parse import urlparse, unquote
66from searx import logger
77from searx.engines import engines
88from searx.metrology.error_recorder import record_error
9+from searx import settings
910
1011
1112CONTENT_LEN_IGNORED_CHARS_REGEX = re.compile(r'[,;:!?\./\\\\ ()-_]', re.M | re.U)
@@ -129,13 +130,18 @@ def merge_two_infoboxes(infobox1, infobox2):
129130 infobox1['content'] = content2
130131
131132
132−def result_score(result):
133+def result_score(result, language):
133134 weight = 1.0
134135
135136 for result_engine in result['engines']:
136137 if hasattr(engines[result_engine], 'weight'):
137138 weight *= float(engines[result_engine].weight)
138139
140+ if settings['search']['prefer_configured_language']:
141+ domain_parts = result['parsed_url'].netloc.split('.')
142+ if language in domain_parts:
143+ weight *= 1.1
144+
139145 occurences = len(result['positions'])
140146
141147 return sum((occurences * weight) / position for position in result['positions'])
@@ -145,9 +151,10 @@ class ResultContainer:
145151 """docstring for ResultContainer"""
146152
147153 __slots__ = '_merged_results', 'infoboxes', 'suggestions', 'answers', 'corrections', '_number_of_results',\
148− '_ordered', 'paging', 'unresponsive_engines', 'timings', 'redirect_url', 'engine_data'
154+ '_ordered', 'paging', 'unresponsive_engines', 'timings', 'redirect_url', 'engine_data',\
155+ '_language'
149156
150− def __init__(self):
157+ def __init__(self, language):
151158 super().__init__()
152159 self._merged_results = []
153160 self.infoboxes = []
@@ -161,6 +168,7 @@ class ResultContainer:
161168 self.unresponsive_engines = set()
162169 self.timings = []
163170 self.redirect_url = None
171+ self._language = language.lower().split('-')[0]
164172
165173 def extend(self, engine_name, results):
166174 standard_result_count = 0
@@ -299,7 +307,7 @@ class ResultContainer:
299307
300308 def order_results(self):
301309 for result in self._merged_results:
302− score = result_score(result)
310+ score = result_score(result, self._language)
303311 result['score'] = score
304312 with RLock():
305313 for result_engine in result['engines']: