added synonym readme
This commit is contained in:
parent
aee9556afa
commit
322b30c724
@ -71,4 +71,13 @@ __notes:__
|
||||
|
||||
- The column `adm0_a3` will be used as a unique identifier.
|
||||
- The ranks are somewhat arbitrarily organized and should be modified later based on our users use of the geocoder (will users more commonly geocode an adm0_a3 or abbreviation?)
|
||||
- I also forgot to assign a `rank` of `2` to a synonym.
|
||||
- I also forgot to assign a `rank` of `2` to a synonym.
|
||||
|
||||
# Admin0 Synonym Service
|
||||
|
||||
If you need to look up the iso code for any list of countries without returning any geometries, you can use the endpoint defined in sql/synonym_service.sql. An example works like this,
|
||||
|
||||
```sql
|
||||
SELECT (admin0_synonym_lookup(Array['United States', 'ESP'])).*
|
||||
```
|
||||
|
||||
|
@ -10,6 +10,6 @@ CREATE OR REPLACE FUNCTION admin0_synonym_lookup(name text[])
|
||||
BEGIN
|
||||
-- FOR ret IN
|
||||
RETURN QUERY
|
||||
SELECT d.q, n.adm0_a3 FROM (SELECT q, lower(regexp_replace(q, '[^a-zA-Z\u00C0-\u00ff]+', '', 'g'))::text x FROM (SELECT unnest(name) q) g) d LEFT OUTER JOIN admin0_synonyms s ON name_ = d.x GROUP BY d.q, n.adm0_a3;
|
||||
SELECT d.q, s.adm0_a3 FROM (SELECT q, lower(regexp_replace(q, '[^a-zA-Z\u00C0-\u00ff]+', '', 'g'))::text x FROM (SELECT unnest(name) q) g) d LEFT OUTER JOIN admin0_synonyms s ON name_ = d.x GROUP BY d.q, s.adm0_a3;
|
||||
END
|
||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||
|
Loading…
Reference in New Issue
Block a user