]> git.openstreetmap.org Git - nominatim.git/commitdiff
reduce influence of viewbox
authorSarah Hoffmann <lonvia@denofr.de>
Sat, 7 Oct 2023 15:30:01 +0000 (17:30 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sat, 7 Oct 2023 20:00:52 +0000 (22:00 +0200)
Perfectly matching city names should still get priority.

nominatim/api/search/db_searches.py
test/python/api/search/test_search_places.py

index eb4da5490e5f8ad6377cba288908fccdf9d2e79f..e07f7906fa2e8296952841659ee493659b2df8a7 100644 (file)
@@ -518,8 +518,8 @@ class PostcodeSearch(AbstractSearch):
                 sql = sql.where(t.c.geometry.intersects(VIEWBOX_PARAM))
             else:
                 penalty += sa.case((t.c.geometry.intersects(VIEWBOX_PARAM), 0.0),
-                                   (t.c.geometry.intersects(VIEWBOX2_PARAM), 1.0),
-                                   else_=2.0)
+                                   (t.c.geometry.intersects(VIEWBOX2_PARAM), 0.5),
+                                   else_=1.0)
 
         if details.near is not None:
             if details.near_radius is not None:
@@ -640,8 +640,8 @@ class PlaceSearch(AbstractSearch):
                     sql = sql.where(tsearch.c.centroid.ST_Intersects_no_index(VIEWBOX2_PARAM))
             else:
                 penalty += sa.case((t.c.geometry.intersects(VIEWBOX_PARAM), 0.0),
-                                   (t.c.geometry.intersects(VIEWBOX2_PARAM), 1.0),
-                                   else_=2.0)
+                                   (t.c.geometry.intersects(VIEWBOX2_PARAM), 0.5),
+                                   else_=1.0)
 
         if details.near is not None:
             if details.near_radius is not None:
index d280eeee463fd87de85605144e5e1b2e96a0a035..3853439f234a62dd16848711d2c3e4c7467d5d43 100644 (file)
@@ -159,7 +159,7 @@ class TestNameOnlySearches:
     @pytest.mark.parametrize('wcount,rids', [(2, [100, 101]), (20000, [100])])
     def test_prefer_viewbox(self, apiobj, viewbox, wcount, rids):
         lookup = FieldLookup('name_vector', [1, 2], 'lookup_all')
-        ranking = FieldRanking('name_vector', 0.9, [RankedTokens(0.0, [21])])
+        ranking = FieldRanking('name_vector', 0.2, [RankedTokens(0.0, [21])])
 
         results = run_search(apiobj, 0.1, [lookup], [ranking])
         assert [r.place_id for r in results] == [101, 100]