Skip to content

Commit

Permalink
Merge pull request #3346 from lonvia/reduce-artificial-importance
Browse files Browse the repository at this point in the history
Reduce default importance
  • Loading branch information
lonvia authored Feb 28, 2024
2 parents 019a68a + c6d40d4 commit 1879cf9
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib-sql/functions/importance.sql
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ BEGIN

-- 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 %}
Expand Down
2 changes: 1 addition & 1 deletion nominatim/api/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def calculated_importance(self) -> float:
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:
Expand Down
2 changes: 1 addition & 1 deletion nominatim/api/search/db_searches.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ async def lookup(self, conn: SearchConnection,
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)


Expand Down
2 changes: 1 addition & 1 deletion test/python/api/test_result_formatting_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_search_details_minimal():
'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,
Expand Down
2 changes: 1 addition & 1 deletion test/python/api/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_minimal_detailed_result():

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,
Expand Down

0 comments on commit 1879cf9

Please sign in to comment.