datagovuk / apiserver

Prototype "NII Data->API" Service
15 stars 3 forks source link

Postcode searches not working? #63

Closed wood-chris closed 8 years ago

wood-chris commented 8 years ago

I'm not sure if this is the best place to report this... but:

I've noticed that the postcode searches on the Linked Data Transport API don't seem to return any results. e.g:

Results from Find railway stations near to a postcode (distance in km): https://data.gov.uk/data/api/service/transport/naptan_railway_stations/postcode?postcode=NW1%201AH&distance=10

These happen regardless of the format of the postcode (e.g. NW1 1AH or NW11AH) and happens with both full and partial postcode searches (and I've checked the postcodes are real and valid!)

However, the partial postcode searches for the Health Data API do work: e.g.

Find hospitals using just a partial postcode (e.g. CH64, or L1): https://data.gov.uk/data/api/service/health/hospitals/partial_postcode?partial_postcode=CH2

rossjones commented 8 years ago

Thanks for reporting this, it is indeed the best place to report it.

The reason one works and the other doesn't is that the full postcode searches are using codepoint and some of the postcodes in our import are not normalised (they still seem to have spaces in).

update codepoint set postcode=normalise_postcode(postcode);

seems to have fixed this. https://data.gov.uk/data/api/service/transport/naptan_railway_stations/postcode?postcode=NW1%201AH&distance=10 is working for me now, although we probably need to check the ordering of the results.