pelias / api

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

Query filters for parent data fields #1646

Open mansoor-sajjad opened 1 year ago

mansoor-sajjad commented 1 year ago

We can filter the results by country using pelias-api, by using the boundary.country query parameter which will target the country abbreviation field (country_a) under the parents.

We want to have the ability to filter on other parent fields also, may be on Ids instead of abbreviation field.

We are currently using the forked version of pelias-api where we have added ability to search on locality_id and county_id. But this is very specific to out needs. We may find a general solution to filter on any parent field.

missinglink commented 1 year ago

Can boundary.gid be used to replace your forked version which filters on locality_id and county_id?

eg. https://pelias.github.io/compare/#/v1/autocomplete?boundary.gid=whosonfirst%3Alocality%3A1495123997&text=cafe

mansoor-sajjad commented 1 year ago

Hi @missinglink,

I have analyzed this option and our requirement. boundary.gid is a nice option but it a very limited, it let us filter the results only on one gid, but we need to filter on multiple localities and counties.

I have analyzed the option to extend boundary.gid to boundary.gids Which basically means that we will extend the elasticsearch filter query to multiple values. But then it will be a OR filter across all the parents. And what we are looking for is the Localities AND Counties filter. i.e. separate elasticsearch filter for Localities and Counties so that it will be OR within the single filter and AND across the filters.

For example: https://api.entur.io/geocoder/v1/autocomplete?lang=no&text=tro&boundary.locality_ids=KVE:TopographicPlace:5001,KVE:TopographicPlace:1820&boundary.county_ids=KVE:TopographicPlace:18,KVE:TopographicPlace:50

Here we are querying the results which have any of the given locality_ids AND any of given county_ids.

arnesetzer commented 1 year ago

A general purpose boundary.gid like boundary.gid=whosonfirst:region:85681677,whosonfirst:region:85682571 would be a very cool feature. That would simplify a mashup of the boundary.country and the boundary.rectangle filter, which still does not fit our search area completly.