algolia / places

:globe_with_meridians: Turn any <input> into an address autocomplete
https://community.algolia.com/places/
MIT License
5.35k stars 234 forks source link

Missing city name #243

Closed jonashaag closed 8 years ago

jonashaag commented 8 years ago

Not sure if this is the right place to file this issue, it seems more like an issue with the REST API/places-dsn, whose source code I haven't found anywhere.

When I search for a street in my city (Karlsruhe, Germany), the result doesn't include the city name. Instead it shows the federal state (which is very uncommon to show in Germany btw), which isn't helpful at all, because streets are not unique within states ;)

screen shot 2016-06-21 at 10 01 55

(GPS coordinates are correct btw)

Result JSON:

{"hits":[{"is_city":false,"is_country":false,"_tags":["highway","highway/primary","country/de","address"],"postcode":[],"country_code":"de","country":"Germany","admin_level":15,"locale_names":["Kriegsstraße"],"importance":26,"is_popular":false,"county":["Karlsruhe"],"suburb":["Weststadt"],"is_highway":true,"administrative":["Baden-Württemberg","Regierungsbezirk Karlsruhe"],"population":0,"_geoloc":{"lat":49.0055,"lng":8.3813},"objectID":"51506287_3527965","_highlightResult":{"country":{"value":"Germany","matchLevel":"none","matchedWords":[]},"locale_names":[{"value":"<em>Kriegsstraße</em>","matchLevel":"partial","fullyHighlighted":false,"matchedWords":["kriegsstrasse"]}],"county":[{"value":"<em>Karlsruhe</em>","matchLevel":"partial","fullyHighlighted":true,"matchedWords":["karlsruhe"]}],"suburb":[{"value":"Weststadt","matchLevel":"none","matchedWords":[]}],"administrative":[{"value":"Baden-Württemberg","matchLevel":"none","matchedWords":[]},{"value":"Regierungsbezirk <em>Karlsruhe</em>","matchLevel":"partial","fullyHighlighted":false,"matchedWords":["karlsruhe"]}]}},{"is_city":false,"is_country":false,"_tags":["highway","highway/residential","country/de","address"],"postcode":[],"country_code":"de","country":"Germany","city":["Heidelberg"],"locale_names":["Kriegsstraße"],"admin_level":15,"importance":26,"village":["Handschuhsheim"],"is_popular":false,"is_highway":true,"county":["Heidelberg"],"suburb":["Handschuhsheim"],"administrative":["Baden-Württemberg","Regierungsbezirk Karlsruhe"],"population":152113,"_geoloc":{"lat":49.4292,"lng":8.68619},"objectID":"64169628_24000929","_highlightResult":{"country":{"value":"Germany","matchLevel":"none","matchedWords":[]},"city":[{"value":"Heidelberg","matchLevel":"none","matchedWords":[]}],"locale_names":[{"value":"<em>Kriegsstraße</em>","matchLevel":"partial","fullyHighlighted":false,"matchedWords":["kriegsstrasse"]}],"village":[{"value":"Handschuhsheim","matchLevel":"none","matchedWords":[]}],"county":[{"value":"Heidelberg","matchLevel":"none","matchedWords":[]}],"suburb":[{"value":"Handschuhsheim","matchLevel":"none","matchedWords":[]}],"administrative":[{"value":"Baden-Württemberg","matchLevel":"none","matchedWords":[]},{"value":"Regierungsbezirk <em>Karlsruhe</em>","matchLevel":"partial","fullyHighlighted":false,"matchedWords":["karlsruhe"]}]}},{"is_city":false,"is_country":false,"_tags":["highway","highway/residential","country/de","address"],"postcode":[],"country_code":"de","country":"Germany","city":["Ettlingen"],"locale_names":["Kriegsstraße"],"admin_level":15,"village":["Schöllbronn"],"importance":26,"is_popular":false,"is_highway":true,"county":["Landkreis Karlsruhe"],"administrative":["Baden-Württemberg","Regierungsbezirk Karlsruhe"],"population":38819,"_geoloc":{"lat":48.893,"lng":8.42016},"objectID":"83001950_106664831","_highlightResult":{"country":{"value":"Germany","matchLevel":"none","matchedWords":[]},"city":[{"value":"Ettlingen","matchLevel":"none","matchedWords":[]}],"locale_names":[{"value":"<em>Kriegsstraße</em>","matchLevel":"partial","fullyHighlighted":false,"matchedWords":["kriegsstrasse"]}],"village":[{"value":"Schöllbronn","matchLevel":"none","matchedWords":[]}],"county":[{"value":"Landkreis <em>Karlsruhe</em>","matchLevel":"partial","fullyHighlighted":false,"matchedWords":["karlsruhe"]}],"administrative":[{"value":"Baden-Württemberg","matchLevel":"none","matchedWords":[]},{"value":"Regierungsbezirk <em>Karlsruhe</em>","matchLevel":"partial","fullyHighlighted":false,"matchedWords":["karlsruhe"]}]}},{"is_city":false,"is_country":false,"_tags":["highway","highway/secondary","country/de","address"],"postcode":[],"country_code":"de","country":"Germany","city":["Bad Wildbad"],"locale_names":["Kriegsstraße"],"admin_level":15,"importance":26,"is_popular":false,"is_highway":true,"county":["Verwaltungsgemeinschaft Bad Wildbad"],"suburb":["Calmbach"],"administrative":["Baden-Württemberg","Regierungsbezirk Karlsruhe"],"population":10393,"_geoloc":{"lat":48.7765,"lng":8.57863},"objectID":"75805823_67919665","_highlightResult":{"country":{"value":"Germany","matchLevel":"none","matchedWords":[]},"city":[{"value":"Bad Wildbad","matchLevel":"none","matchedWords":[]}],"locale_names":[{"value":"<em>Kriegsstraße</em>","matchLevel":"partial","fullyHighlighted":false,"matchedWords":["kriegsstrasse"]}],"county":[{"value":"Verwaltungsgemeinschaft Bad Wildbad","matchLevel":"none","matchedWords":[]}],"suburb":[{"value":"Calmbach","matchLevel":"none","matchedWords":[]}],"administrative":[{"value":"Baden-Württemberg","matchLevel":"none","matchedWords":[]},{"value":"Regierungsbezirk <em>Karlsruhe</em>","matchLevel":"partial","fullyHighlighted":false,"matchedWords":["karlsruhe"]}]}},{"is_city":false,"is_country":false,"_tags":["highway","highway/residential","country/de","address"],"postcode":[],"country_code":"de","country":"Germany","city":["Dielheim"],"locale_names":["Kriegsstraße"],"admin_level":15,"importance":26,"is_popular":false,"is_highway":true,"county":["Verwaltungsgemeinschaft Wiesloch"],"suburb":["Dielheim"],"administrative":["Baden-Württemberg","Regierungsbezirk Karlsruhe"],"population":8981,"_geoloc":{"lat":49.2834,"lng":8.73007},"objectID":"65737909_28882976","_highlightResult":{"country":{"value":"Germany","matchLevel":"none","matchedWords":[]},"city":[{"value":"Dielheim","matchLevel":"none","matchedWords":[]}],"locale_names":[{"value":"<em>Kriegsstraße</em>","matchLevel":"partial","fullyHighlighted":false,"matchedWords":["kriegsstrasse"]}],"county":[{"value":"Verwaltungsgemeinschaft Wiesloch","matchLevel":"none","matchedWords":[]}],"suburb":[{"value":"Dielheim","matchLevel":"none","matchedWords":[]}],"administrative":[{"value":"Baden-Württemberg","matchLevel":"none","matchedWords":[]},{"value":"Regierungsbezirk <em>Karlsruhe</em>","matchLevel":"partial","fullyHighlighted":false,"matchedWords":["karlsruhe"]}]}}],"nbHits":5,"processingTimeMS":45,"query":"kriegsstrasse karlsruhe","params":"hitsPerPage=5&language=en&aroundLatLng=49.006783299999995%2C8.3833701&query=kriegsstrasse%20karlsruhe","degradedQuery":false}
redox commented 8 years ago

Thank you for the bug report @jonashaag; we'll look at it. It looks like the same situation than #227

redox commented 8 years ago

hey @jonashaag; I look again at the data OSM is providing and our next results will fit what their search is also retrieving: http://www.openstreetmap.org/search?query=kriegstrasse%20Karlsruhe

The city is Pforzheim, part of Regierungsbezirk Karlsruhe. Does that make sense or is there an issue with the OSM data?

jonashaag commented 8 years ago

You're missing the second s in your query, it's Kriegsstrasse and OSM correctly shows Karlsruhe as city

redox commented 8 years ago

You're missing the second s in your query, it's Kriegsstrasse and OSM correctly shows Karlsruhe as city

Arg good catch; I'll export the Karlsruhe region from OSM and dig deeper to understand why those streets are not selected by our importer.

redox commented 8 years ago

Alright, so for an unknown reason; the OSM export doesn't provide the city (with isaddress="t") for that street:

  <feature place_id="324065" type="W" id="4211469" key="highway" value="primary" rank="26" importance="26" parent_place_id="938369" parent_type="R" parent_id="63387">
   <names>
    <name type="name">Kriegsstraße</name>
    <name type="name:de">Kriegsstraße</name>
    <name type="ref">B 10</name>
   </names>
   <adminLevel>15</adminLevel>
   <address>
    <state rank="11" type="R" id="907219" key="place" value="postcode" distance="0.0150828926399484" isaddress="t"/>
    <county rank="12" type="R" id="62518" key="boundary" value="administrative" distance="0.0294789211019574" isaddress="t"/>
    <city rank="16" type="N" id="240046032" key="place" value="city" distance="0.339084718282157" isaddress="f"/>
    <city rank="16" type="N" id="240060919" key="place" value="city" distance="0.491265843047939" isaddress="f"/>
    <suburb rank="20" type="R" id="63387" key="boundary" value="administrative" distance="0.00804776731717723" isaddress="t"/>
   </address>
   <tags>
    <tag type="lanes">4</tag>
    <tag type="maxspeed">50</tag>
   </tags>
   <osmGeometry>LINESTRING(8.3837317 49.0054633,8.3838125 49.0054606)</osmGeometry>
  </feature>

I'll interpolate it from the suburb 👍

jonashaag commented 8 years ago

Maybe because the street goes through multiple sub cities (west south east etc) that each have their own name

redox commented 8 years ago

Fixed ✅