Use housenumber instead of streetnumber for street addresses - #1098
Conversation
|
Can be solved by #1099 with optional settings |
Index addr:housenumber on the street address, so that the conscription number and the combined form (e.g. 100/9) stay searchable in CZ/SK. Place-based addresses keep using addr:conscriptionnumber, so the orientation number does not leak into the place-based display name.
|
Reopening this: following the discussion in #1099, the agreed rule is exactly this change — |
|
The failing test case is interesting: an |
A few hundred addresses, mostly in Slovakia, carry addr:street and addr:streetnumber but no addr:housenumber. Rather than dropping them, fall back to the street number when the house number yields no usable value.
|
Good catch, and I agree that being forgiving is better than dropping those addresses. Implemented as you suggested: the street address now falls back to private void addStreetAddress(PhotonDoc base, Map<String, String> address) {
if (!address.containsKey("street")) {
return;
}
String[] housenumbers = splitHousenumber(address, "housenumber");
if (housenumbers.length == 0) {
// Be forgiving about addresses that only carry a street number. That is a tagging
// error, but a few hundred of them exist, mostly in Slovakia.
housenumbers = splitHousenumber(address, "streetnumber");
}
for (String hnr : housenumbers) {
docs.add(new PhotonDoc(base).houseNumber(hnr));
}
}
|
|
That's okay. Do you mind adding an additional test to NominatimConnectorDBTest which covers the case where all three housenumber tags are present? |
Covers addr:housenumber together with addr:conscriptionnumber and addr:streetnumber: the street address gets the combined form, the place address keeps the conscription number.
|
Added |
|
Thanks, that looks good now. There is a small chance that you see issues with ordering for results with addr:streetnumber+addr:street searches. If that is the case, then please open an issue and we'll need to have a look at adapting the houesnumber index after all. |
In Czechia, house numbers are commonly represented as a combination of conscription number and street number (e.g. 2531/80). Both parts are used when referring to an address on a street.
Previously, Photon indexed only the street number for street-based addresses. As a result, searches using the conscription number could fail.
This change indexes the full housenumber value instead. OpenSearch tokenizes values such as 2531/80, making it possible to find the address by:
street number (80)
conscription number (2531)
full house number (2531/80)
This approach avoids creating multiple documents for the same address while improving support for Czech address numbering.
AI assistance disclosure
Per the contribution guidelines: the code change, the added tests and parts of the discussion in this PR were drafted with AI assistance and reviewed by me.
Verification on a live installation
Verified on a running photon server with the embedded OpenSearch, not only in unit tests. A JSON dump with three addresses was imported twice, once with the current master behaviour and once with this change, and each running server was queried over HTTP.
Test addresses (the
addresspart of each dump entry):street=Kaprova,city=Praha,conscriptionnumber=2531,streetnumber=80,housenumber=2531/80place=Lhota,city=Lhota,conscriptionnumber=100,housenumber=100street=Hlavna,city=Bratislava,streetnumber=34(nohousenumber)House number returned per query:
Kaprova 2531/80802531/80Kaprova 80802531/80Kaprova 25312531/80Lhota 100100100Hlavna 343434Both imports produce three documents, so no duplicate documents are created: the combined value is indexed once and the house number analyzer splits it. The conscription number becomes searchable and the canonical
2531/80is returned. The place-based address is unchanged, and address 3, which only carriesaddr:streetnumber, still resolves thanks to the fallback.