komoot / photon

an open source geocoder for openstreetmap data
Apache License 2.0
1.96k stars 286 forks source link

Filter by country (code) #175

Open Aleksio opened 9 years ago

Aleksio commented 9 years ago

I'm trying to filter the search results by country code, but can't seem to do so. The readme states I can use the nominatim source as reference, and that includes country_code but I can't get it to work.

Is it actually supported? Or is the query incorrect?

http://photon.komoot.de/api?q=berlin&osm_tag=country_code:DE http://photon.komoot.de/api?q=berlin&osm_tag=country:DE

christophlingg commented 9 years ago

hi @Aleksio, it is not possible to query any kind of osm tag, just the one that got considered by nominatim. For example, this query works: http://photon.komoot.de/api?q=berlin&osm_tag=place:city

Can you see the osm_tag and osm_value field of the response. That are the attributes where the filter apply.

Aleksio commented 9 years ago

Thanks for the quick reply, I merely looked at the list provided here: https://github.com/openstreetmap/osm2pgsql/blob/master/output-gazetteer.cpp#L81

Is it in any way possible to filter results by country(code), so we can provide means to our users to get more accurate results? Or is such feature planned in the future?

christophlingg commented 9 years ago

we haven't planned to implement such a feature yet. do you always want german results only? you could simple delete all non german items from the index, queries can only return german items then.

Aleksio commented 9 years ago

Unfortunately not, that was only for example. The usage is international, so being able to filter by country code would be ideal.

amenzhinsky commented 9 years ago

I would be nice to have this feature done

1tft commented 6 years ago

Hello, does anyone has a quick elastic query for deleting whole countries from elastic photon indice?

1tft commented 6 years ago

I used following query and after that fired also curl -XPUT 'http://localhost:9200/photon/_settings?preserve_existing=true' -d '{ index.merge.policy.expunge_deletes_allowed" : "0" }' and curl -X POST "localhost:9200/photon/_forcemerge?only_expunge_deletes" to purge index.

curl -X POST "http://localhost:9200/photon/place/_delete_by_query?pretty" -H 'Content-Type: application/json' -d' { "query": { "bool": { "must": { "match": { "collector.en.raw": { "query": "Afghanistan, Albania, Algeria", "operator": "or", "analyzer": "index_raw" } } } } } }'

expressIndustries commented 5 years ago

How would I delete all elastic photon indices EXCEPT one country? IE: everything BUT Canada ?

1tft commented 5 years ago

@expressIndustries Try to us instead of "must" a "must_not" delete query.

expressIndustries commented 5 years ago

Ok. thanks. Working on getting a USA only photon database up and running with TIGER street addresses...but having trouble getting TIGER data to load into Nominatim. Nothing happens when I run the import command: no errors are thrown and no new tables or indexes are created in nominatim database. Stumped at the moment.

Curious if loading the graphopper DB and then removing all other countries except USA using Elasticsearch query would be similar result as trying to load all US States from Geographik and then load TIGER. Any idea?

lonvia commented 5 years ago

Your comment is off-topic for this ticket. For questions about installation and use of photon please use [the mailing list])(https://lists.openstreetmap.org/listinfo/photon).

verybigelephants commented 4 years ago

this would be truly wonderful to have such option

choesterle commented 4 years ago

Where is the accurate list for the supported tags and values? The one provided in the readme.md (https://github.com/openstreetmap/osm2pgsql/blob/master/output-gazetteer.cpp#L81) doesn't seem to work anymore

wottpal commented 3 years ago

👍

mickey-connectit commented 7 months ago

Where is the accurate list for the supported tags and values? The one provided in the readme.md (https://github.com/openstreetmap/osm2pgsql/blob/master/output-gazetteer.cpp#L81) doesn't seem to work anymore

I'm finding it similarly difficult to figure out what tags and values are supported. I would also like to filter the results by country code (or even by the state key on the returned JSON object) but it doesn't seem that this is possible.

alexboss commented 6 months ago

Indeed, would be a very helpful feature. Hope it will be implemented someday. Thanks for the Photon project anyway.

TheJanzap commented 2 months ago

IMO there's two ways this could be implemented: Either have something similar to Nominatim's countrycodes parameter, or a generalized filter that works for everything in the "properties" node (or even the "geography" node) that the API responds with.

The former would probably be easier to implement, while the latter offers more flexibility.