]> git.openstreetmap.org Git - nominatim.git/commitdiff
reduce importance when computed from search rank
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 9 Feb 2024 08:16:11 +0000 (09:16 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Tue, 27 Feb 2024 09:15:54 +0000 (10:15 +0100)
lib-sql/functions/importance.sql
nominatim/api/results.py
nominatim/api/search/db_searches.py
test/python/api/test_result_formatting_v1.py
test/python/api/test_results.py

index 6c089d824b99565a72ad9de6202c5fd1f6ae5b2b..9b2fb7737ff20f8724f5003aba13da14ab42cab8 100644 (file)
@@ -130,7 +130,7 @@ BEGIN
 
   -- Still nothing? Fall back to a default.
   IF result.importance is null THEN
 
   -- Still nothing? Fall back to a default.
   IF result.importance is null THEN
-    result.importance := 0.75001 - (rank_search::float / 40);
+    result.importance := 0.40001 - (rank_search::float / 75);
   END IF;
 
 {% if 'secondary_importance' in db.tables %}
   END IF;
 
 {% if 'secondary_importance' in db.tables %}
index 9b67c51aa580ef38befd5e9efb80ed7b7885b825..fa861bf3fafbe0a90d736e19491bf83c0cd317e6 100644 (file)
@@ -233,7 +233,7 @@ class BaseResult:
             of the value or an artificial value computed from the place's
             search rank.
         """
             of the value or an artificial value computed from the place's
             search rank.
         """
-        return self.importance or (0.7500001 - (self.rank_search/40.0))
+        return self.importance or (0.40001 - (self.rank_search/75.0))
 
 
     def localize(self, locales: Locales) -> None:
 
 
     def localize(self, locales: Locales) -> None:
index 555819e7451dac76042482cd101ffbdfd067c882..b3aed35fdf77cba3beed58ad89342ff499e0293d 100644 (file)
@@ -700,7 +700,7 @@ class PlaceSearch(AbstractSearch):
                or (details.viewbox is not None and details.viewbox.area < 0.5):
                 sql = sql.order_by(
                         penalty - sa.case((tsearch.c.importance > 0, tsearch.c.importance),
                or (details.viewbox is not None and details.viewbox.area < 0.5):
                 sql = sql.order_by(
                         penalty - sa.case((tsearch.c.importance > 0, tsearch.c.importance),
-                                    else_=0.75001-(sa.cast(tsearch.c.search_rank, sa.Float())/40)))
+                                    else_=0.40001-(sa.cast(tsearch.c.search_rank, sa.Float())/75)))
             sql = sql.add_columns(t.c.importance)
 
 
             sql = sql.add_columns(t.c.importance)
 
 
index 0c54667ead80b86180ff8e1d654fec0ae17bc42e..0ff834a4549332ad589f39d958af17df00970649 100644 (file)
@@ -77,7 +77,7 @@ def test_search_details_minimal():
             'admin_level': 15,
             'names': {},
             'localname': '',
             'admin_level': 15,
             'names': {},
             'localname': '',
-            'calculated_importance': pytest.approx(0.0000001),
+            'calculated_importance': pytest.approx(0.00001),
             'rank_address': 30,
             'rank_search': 30,
             'isarea': False,
             'rank_address': 30,
             'rank_search': 30,
             'isarea': False,
index 2a279028b370cb4815684609b3b4dc4365ad5c3b..54a5454945860618a61ebf01317871b9db90cc4d 100644 (file)
@@ -37,7 +37,7 @@ def test_minimal_detailed_result():
 
     assert res.lon == 23.1
     assert res.lat == 0.5
 
     assert res.lon == 23.1
     assert res.lat == 0.5
-    assert res.calculated_importance() == pytest.approx(0.0000001)
+    assert res.calculated_importance() == pytest.approx(0.00001)
 
 def test_detailed_result_custom_importance():
     res = DetailedResult(SourceTable.PLACEX,
 
 def test_detailed_result_custom_importance():
     res = DetailedResult(SourceTable.PLACEX,