From 6f11b61cd5eebd0d9b046be20f4f225803279c67 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Mon, 13 Sep 2021 08:37:25 +0200 Subject: [PATCH 1/2] [fix] openstreetmap engine: map "all" language to English --- searx/engines/openstreetmap.py | 1 + 1 file changed, 1 insertion(+) diff --git a/searx/engines/openstreetmap.py b/searx/engines/openstreetmap.py index 9f1fe94c..07d53672 100644 --- a/searx/engines/openstreetmap.py +++ b/searx/engines/openstreetmap.py @@ -220,6 +220,7 @@ def fetch_wikidata(nominatim_json, user_langage): wd_to_results.setdefault(wd_id, []).append(result) if wikidata_ids: + user_langage = 'en' if user_langage == 'all' else user_langage wikidata_ids_str = " ".join(wikidata_ids) query = wikidata_image_sparql.replace('%WIKIDATA_IDS%', sparql_string_escape(wikidata_ids_str)).replace( '%LANGUAGE%', sparql_string_escape(user_langage) From ab569c1e12672a2d54a51738863b37d2261de5f5 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sat, 25 Sep 2021 11:16:22 +0200 Subject: [PATCH 2/2] [fix] openstreetmap engine: optmizer SPARQL query add hint:Query hint:optimizer "None". to the SPARQL query to keep the response time small. It tells the optimizer to follow the path from ?item to the different property values instead of the other way around. See https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/query_optimization#Property_paths --- searx/engines/openstreetmap.py | 1 + 1 file changed, 1 insertion(+) diff --git a/searx/engines/openstreetmap.py b/searx/engines/openstreetmap.py index 07d53672..c6211a00 100644 --- a/searx/engines/openstreetmap.py +++ b/searx/engines/openstreetmap.py @@ -42,6 +42,7 @@ route_re = re.compile('(?:from )?(.+) to (.+)') wikidata_image_sparql = """ select ?item ?itemLabel ?image ?sign ?symbol ?website ?wikipediaName where { + hint:Query hint:optimizer "None". values ?item { %WIKIDATA_IDS% } OPTIONAL { ?item wdt:P18|wdt:P8517|wdt:P4291|wdt:P5252|wdt:P3451|wdt:P4640|wdt:P5775|wdt:P2716|wdt:P1801|wdt:P4896 ?image } OPTIONAL { ?item wdt:P1766|wdt:P8505|wdt:P8667 ?sign }