photon icon indicating copy to clipboard operation
photon copied to clipboard

Filter by country (code)

Open Aleksio opened this issue 9 years ago • 17 comments

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

Aleksio avatar Jul 07 '15 22:07 Aleksio

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.

christophlingg avatar Jul 08 '15 15:07 christophlingg

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?

Aleksio avatar Jul 08 '15 17:07 Aleksio

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.

christophlingg avatar Jul 09 '15 07:07 christophlingg

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

Aleksio avatar Jul 09 '15 13:07 Aleksio

I would be nice to have this feature done

amenzhinsky avatar Oct 05 '15 09:10 amenzhinsky

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

1tft avatar Sep 26 '18 19:09 1tft

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" } } } } } }'

1tft avatar Sep 27 '18 21:09 1tft

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

expressIndustries avatar Dec 20 '18 06:12 expressIndustries

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

1tft avatar Dec 20 '18 07:12 1tft

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?

expressIndustries avatar Dec 20 '18 07:12 expressIndustries

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).

lonvia avatar Dec 20 '18 07:12 lonvia

this would be truly wonderful to have such option

verybigelephants avatar Aug 20 '20 09:08 verybigelephants

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

choesterle avatar Sep 28 '20 13:09 choesterle

👍

wottpal avatar Jul 09 '21 11:07 wottpal

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.

mickey-connectit avatar Apr 18 '24 17:04 mickey-connectit