algolia / places

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

Missing "Administrative" Value for New York City #418

Closed toddlevy closed 6 years ago

toddlevy commented 7 years ago

BUG

What is the current behavior?

Upon doing a city-based places search for "New York" and selecting "New York City" the response does not include the "Administrative" value (which should be "New York," as in the state of New York).

To replicate, go here and do as noted above... https://community.algolia.com/places/

What is the expected behavior?

The expected behavior is to have the "administrative" node populated with the name of the state.

Every other major US city I've tried works just swell.

Thanks for any help resolving this.

raphi commented 7 years ago

Hi @toddlevy

Indeed this is a bug. I will investigate this one.

Thanks!

ghost commented 7 years ago

I have the same problem with a city in IT, "Bergamo".

Query: {"query": "Bergamo", "countries": ["it"],"hitsPerPage":1,"aroundLatLngViaIP":false}

The response misses the "administrative" field.

EDIT: I'll report here below cities I've found with this problem within countries it,gb,de,fr IT: Bergamo, Torino, Cagliari, Agrigento

GB: Edinburgh, Nottingham, Worcester, Cambridge, Exeter, Canterbury, Burnley, Gloucester

FR: Colmar, Bourges, Pierrelatte,Pau,Saint-Brieuc,Luynes,Oloron-Sainte-Marie,Chinon,Bouguenais,Bourgueil,Rezé,Château-la-Vallière,Gassin,Plérin,Fontenay-le-Fleury,Bouaye,Base Alfred Faure,Prades,Bourg-de-Péage,Toulouges,Azay-le-RideauCerbère,Plouescat,Papeete,Boulouparis ... and quite a lot more.

DE: Verbent, Jülich, Oberursel, Dormagen, Marl, Baesweiler, Lohmar, Recklinghausen, Premnitz, Dornstetten, Wesseling, Nordhausen, Rheinberg, Hardegsen, Schwallungen ... and a lot more.

JonathanMontane commented 6 years ago

@toddlevy @lucaJTM There was a processing issue that was fixed in the latest release. Thanks for the report and the nice list of test cases, it helped a lot!

@toddlevy for your specific case, if you go check directly the demo on https://community.algolia.com/places, you will still see the administrative field as missing for New York, but this is UI choice rather than a bug.

It seems that the javascript library default template removes the administrative field if it's identical to the city name (see defaultHit.js#L45), but the data is now present in the response and you just need to define your own template the way you want it to represent the data.

fanckush commented 5 years ago

"you just need to define your own template..." The suggestion still does not have the value of the administrative.

templates: {
  value: function (suggestion) {
   console.log("suggestion obj: ", suggestion)
   return suggestion.name
  }
}

What I get does not contain the administrative. I can only access it from the hit.suggestions[0] but NOT in the template.value

administrative: undefined
city: undefined
country: "United States of America"
countryCode: "us"
county: undefined
latlng: {lat: 40.7309, lng: -73.9872}
name: "New York"
postcode: "10001"
postcodes: ["10001", "10002", "10003", "10004", "10005", "10006", "10007", "10008", "10009", "10010", …] (145)
suburb: undefined
type: "city"
imns commented 4 years ago

I'm also seeing this same behavior and can only access the administrative value via hit.suggestions[0].