pelias / api

HTTP API for Pelias Geocoder
http://pelias.io
MIT License
221 stars 162 forks source link

Layers are not filtered correctly in the Search API #1391

Closed mihaicosareanu-bolt closed 4 years ago

mihaicosareanu-bolt commented 4 years ago

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 :innocent:

https://pelias.github.io/compare/#/v1/search%3Ftext=Aleea%20Ilia%2057&layers=venue,address&focus.point.lat=44.4378&focus.point.lon=26.0245


Here's what I got :scream_cat:

Notice the "layer":"street" in the properties, although in the request I filtered only "venue" and "address" layers.

{
  "geocoding": {
    "version": "0.2",
    "attribution": "https://geocode.earth/guidelines",
    "query": {
      "text": "Aleea Ilia 57",
      "size": 10,
      "layers": [
        "venue",
        "address"
      ],
      "private": false,
      "focus.point.lat": 44.4378,
      "focus.point.lon": 26.0245,
      "lang": {
        "name": "English",
        "iso6391": "en",
        "iso6393": "eng",
        "defaulted": false
      },
      "querySize": 20,
      "parser": "libpostal",
      "parsed_text": {
        "street": "aleea ilia",
        "number": "57"
      }
    },
    "engine": {
      "name": "Pelias",
      "author": "Mapzen",
      "version": "1.0"
    },
    "timestamp": 1574171084378
  },
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          26.149821,
          44.444454
        ]
      },
      "properties": {
        "id": "polyline:8918983",
        "gid": "openstreetmap:street:polyline:8918983",
        "layer": "street",
        "source": "openstreetmap",
        "source_id": "polyline:8918983",
        "name": "Aleea Ilia",
        "street": "Aleea Ilia",
        "confidence": 0.8,
        "match_type": "fallback",
        "distance": 9.988,
        "accuracy": "centroid",
        "country": "Romania",
        "country_gid": "whosonfirst:country:85633745",
        "country_a": "ROU",
        "region": "Bucharest",
        "region_gid": "whosonfirst:region:85687595",
        "region_a": "BI",
        "locality": "Bucharesti",
        "locality_gid": "whosonfirst:locality:101751949",
        "neighbourhood": "Coloniști",
        "neighbourhood_gid": "whosonfirst:neighbourhood:85901737",
        "continent": "Europe",
        "continent_gid": "whosonfirst:continent:102191581",
        "label": "Aleea Ilia, Bucharesti, Romania"
      },
      "bbox": [
        26.149574,
        44.444427,
        26.150068,
        44.44448
      ]
    }
  ],
  "bbox": [
    26.149574,
    44.444427,
    26.150068,
    44.44448
  ]
}

Here's what I was expecting :sparkles:

I was expecting am empty features array, or an array that doesn't contain entries with "layer":"street"

Here's what I think could be improved :trophy:

Figure if there's a bug in filtering the results by layers.

missinglink commented 4 years ago

Yes I agree this is not as expected.

This is caused by the same logic which changed the "match_type" to "fallback" in the geojson you posted above.

So if you're looking for an address and we didn't find one then we fall back to the street centroid.

At that time the filter isn't being honoured correctly.