Skip to content

WOF postal codes not found in autocomplete without full text #676

@pjsier

Description

@pjsier

Hey team!

I was using your awesome geocoding engine when I noticed something interesting.
Let me tell you more about it.


Here's what I did 😇

/v1/autocomplete?sources=wof&layers=postalcode&boundary.country=usa&text=6064


Here's what I got 🙀

{
  "geocoding": {
    "version": "0.2",
    "attribution": "http://pelias.mapzen.com/v1/attribution",
    "query": {
      "text": "6064",
      "parser": "addressit",
      "tokens": [
        "6064"
      ],
      "size": 10,
      "layers": [
        "postalcode"
      ],
      "sources": [
        "whosonfirst"
      ],
      "private": false,
      "boundary.country": "USA",
      "lang": {
        "name": "English",
        "iso6391": "en",
        "iso6393": "eng",
        "defaulted": false
      }
    },
    "engine": {
      "name": "Pelias",
      "author": "Mapzen",
      "version": "1.0"
    },
    "timestamp": 1508853654883
  },
  "type": "FeatureCollection",
  "features": []
}

Here's what I was expecting ✨

I was expecting the results to include the zip code 60640, which is returned if the search query is "60640" as seen here: https://mapzen.github.io/search-sandbox/?query=autocomplete&text=60640&sources=whosonfirst&layers=postalcode&boundary.country=usa

[
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -87.662604,
          41.972872
        ]
      },
      "properties": {
        "id": "554783423",
        "gid": "whosonfirst:postalcode:554783423",
        "layer": "postalcode",
        "source": "whosonfirst",
        "source_id": "554783423",
        "name": "60640",
        "postalcode": "60640",
        "postalcode_gid": "whosonfirst:postalcode:554783423",
        "accuracy": "centroid",
        "country": "United States",
        "country_gid": "whosonfirst:country:85633793",
        "country_a": "USA",
        "region": "Illinois",
        "region_gid": "whosonfirst:region:85688697",
        "region_a": "IL",
        "county": "Cook County",
        "county_gid": "whosonfirst:county:102084317",
        "localadmin": "Chicago",
        "localadmin_gid": "whosonfirst:localadmin:404496273",
        "locality": "Chicago",
        "locality_gid": "whosonfirst:locality:85940195",
        "continent": "North America",
        "continent_gid": "whosonfirst:continent:102191575",
        "label": "60640, Chicago, IL, USA"
      },
      "bbox": [
        -87.67957,
        41.961466,
        -87.634217,
        41.984231
      ]
    }
  ],
  "bbox": [
    -87.67957,
    41.961466,
    -87.634217,
    41.984231
  ]

Here's what I think could be improved 🏆

I'm trying to do an autocomplete search for zip code results alone, but not sure why they're only being returned when the full text is supplied (which I would expect from the search endpoint).

Interestingly, the autocomplete works more like I'd expect with zero-padded zip codes. When I looked for zip code 60618 by typing 6061 (https://mapzen.github.io/search-sandbox/?query=autocomplete&text=6061&sources=whosonfirst&layers=postalcode&boundary.country=usa), the zip code 06061 was returned.

{
  "geocoding": {
    "version": "0.2",
    "attribution": "http://pelias.mapzen.com/v1/attribution",
    "query": {
      "text": "6061",
      "parser": "addressit",
      "tokens": [
        "6061"
      ],
      "size": 10,
      "layers": [
        "postalcode"
      ],
      "sources": [
        "whosonfirst"
      ],
      "private": false,
      "boundary.country": "USA",
      "lang": {
        "name": "English",
        "iso6391": "en",
        "iso6393": "eng",
        "defaulted": false
      }
    },
    "engine": {
      "name": "Pelias",
      "author": "Mapzen",
      "version": "1.0"
    },
    "timestamp": 1508853639640
  },
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -72.96684,
          41.8756
        ]
      },
      "properties": {
        "id": "554766193",
        "gid": "whosonfirst:postalcode:554766193",
        "layer": "postalcode",
        "source": "whosonfirst",
        "source_id": "554766193",
        "name": "06061",
        "postalcode": "06061",
        "postalcode_gid": "whosonfirst:postalcode:554766193",
        "accuracy": "centroid",
        "country": "United States",
        "country_gid": "whosonfirst:country:85633793",
        "country_a": "USA",
        "region": "Connecticut",
        "region_gid": "whosonfirst:region:85688629",
        "region_a": "CT",
        "county": "Litchfield County",
        "county_gid": "whosonfirst:county:102085375",
        "localadmin": "New Hartford",
        "localadmin_gid": "whosonfirst:localadmin:404496029",
        "locality": "New Hartford Center",
        "locality_gid": "whosonfirst:locality:85931237",
        "continent": "North America",
        "continent_gid": "whosonfirst:continent:102191575",
        "label": "06061, New Hartford Center, CT, USA"
      },
      "bbox": [
        -72.978041,
        41.867886,
        -72.957498,
        41.879199
      ]
    }
  ],
  "bbox": [
    -72.978041,
    41.867886,
    -72.957498,
    41.879199
  ]
}

Happy to provide any more context or clarification!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions