Skip to content

Include location bias into rescoring#1051

Merged
lonvia merged 14 commits intokomoot:masterfrom
lonvia:rescore-with-location-bias
Apr 18, 2026
Merged

Include location bias into rescoring#1051
lonvia merged 14 commits intokomoot:masterfrom
lonvia:rescore-with-location-bias

Conversation

@lonvia
Copy link
Copy Markdown
Collaborator

@lonvia lonvia commented Apr 13, 2026

This extends the rescoring algorithm from #1041 to also take into account the score from the location bias. Thus the final OpenSearch score is now neatly split into match score, importance score and location bias score. The location bias score is added such that if nothing suitable is found in the focus area, the rescoring behaves exactly as if no location bias was set at all.

This also changes the size of the focus area (larger for large zooms, smaller for smaller ones) and the default zoom (14 -> 12) and location_bias_score (0.2 -> 0.4).

The PR also adds the output of OpenSearch's explain to the debug output for search. That can be useful to understand how the score came to be.

@henrik242 would you mind checking the effects on your data?

Closes #1024.

Comment thread src/main/java/de/komoot/photon/opensearch/OpenSearchSearchHandler.java Outdated
@henrik242
Copy link
Copy Markdown
Contributor

I'm seeing a couple of unexpected results. Searching for Schw 10 with a focus in Oslo previously gave me Schweigaards gate 10, Oslo (distance: 1 km) as the first result. Now I get Schwartz gate 10, Drammen (distance: 36 km).

@lonvia lonvia force-pushed the rescore-with-location-bias branch from a5ef60d to f89fd7f Compare April 14, 2026 13:35
lonvia added 6 commits April 15, 2026 22:57
Also moves the debug output after the raw_data output.
Reverse doesn't need sorting, so don't waste time on it.
This will allow for reuse later. Also changes the formula slightly.
This allows moving the weight for the score functions out of the
QueryBuilder.
@lonvia lonvia force-pushed the rescore-with-location-bias branch 2 times, most recently from 90a1328 to 5949947 Compare April 17, 2026 09:03
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 5949947. Configure here.

Comment thread src/main/java/de/komoot/photon/opensearch/OpenSearchResult.java Outdated
@lonvia lonvia force-pushed the rescore-with-location-bias branch from 5949947 to b5fb6ee Compare April 17, 2026 14:33
@lonvia
Copy link
Copy Markdown
Collaborator Author

lonvia commented Apr 17, 2026

Added a couple of adjustments to balance out the various use-cases:

  • Added a minor decay in the area of focus, so that results closer to the center come first when all other things are equal.
  • No longer make rematch score depend on length of place name. If doesn't make sense to give "Neuhausen" a lower score than "Neuss" when searching for "Neu" just because the former has more letters.
  • Don't use the strong exact match rescoring when the query contains a comma. A comma indicates that the query is made up of multiple terms and thus shouldn't match against the exact name.
  • When rescoring ends in a 0 score, still give it a small score relative to the place's importance. That allows for a bit of typo-tolerant matching for well-known places.

I've also adjusted the focus radius computation some more. The result seems to be fairly decent for the planet test set. We might do something with getting more result candidates and doing some post-filtering in order to get result list that don't have obvious outliers down the list but that is something for the next version.

@lonvia lonvia merged commit 004b581 into komoot:master Apr 18, 2026
5 checks passed
@lonvia lonvia deleted the rescore-with-location-bias branch April 18, 2026 09:33
henrik242 added a commit to entur/geocoder that referenced this pull request Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search with priority given to a geographic position does not sort results as expected in release 1.0.0

2 participants