Searching the map

Hello everyone,

I am looking for a way to do searches like
“Berliner Allee 2, 79114 Freiburg” and get only the
street named “Berliner Allee” that is in Freiburg.
I know about the web-service to do this but the
search needs to be done offline on a mysql-database
created by osmosis and in java-code.
so: how exactly to find out what zip-code and
city a way is in in an sql-query with or without
helper-tables that contain pre-computed is-in relations.

Is there already a proposal for a relation to
group multiple parts that belong to the same way
in order to display the way onle once in search-results?
Or a concensus how such a relation should look like?

I have seen a lot of such address-forms with only
one textarea that correctly find street-name, house-number,
zip-code, place and optionally state and country.
Does anyone know about good geuristics to implement
such a thing? It looks very user-friendly.

a) AFAIK OSM does not support house numbers ATM. Furthermore most cities are not areas, but points. And MANY zip codes are not recorded in OSM because it sooo boring.

b) First we have to decide what constitutes a single “super way” from the point of the surveyor. You could say the ref is constant and they share at least one node at the end (i.e. touch). Or that the name is constant. Software can implement constant name / ref + touch.

c) I think their input data is super accurate to start with, i.e. lots of well trained map editors, phonebook data etc.
Then they may employ “Approximate matching” ideas to allow for omissions and transpositions. See “tre”, “agrep” and the bitap algorithm.