- rank_search := 30;
- rank_address := 30;
- postcode := upper(postcode);
-
- IF country_code = 'gb' THEN
- IF postcode ~ '^([A-Z][A-Z]?[0-9][0-9A-Z]? [0-9][A-Z][A-Z])$' THEN
- rank_search := 25;
- rank_address := 5;
- ELSEIF postcode ~ '^([A-Z][A-Z]?[0-9][0-9A-Z]? [0-9])$' THEN
- rank_search := 23;
- rank_address := 5;
- ELSEIF postcode ~ '^([A-Z][A-Z]?[0-9][0-9A-Z])$' THEN
- rank_search := 21;
- rank_address := 5;
- END IF;
-
- ELSEIF country_code = 'sg' THEN
- IF postcode ~ '^([0-9]{6})$' THEN
- rank_search := 25;
- rank_address := 11;
- END IF;
-
- ELSEIF country_code = 'de' THEN
- IF postcode ~ '^([0-9]{5})$' THEN
- rank_search := 21;
- rank_address := 11;
- END IF;
-
- ELSE
- -- Guess at the postcode format and coverage (!)
- IF postcode ~ '^[A-Z0-9]{1,5}$' THEN -- Probably too short to be very local
- rank_search := 21;
- rank_address := 11;
- ELSE
- -- Does it look splitable into and area and local code?
- part := substring(postcode from '^([- :A-Z0-9]+)([- :][A-Z0-9]+)$');
-
- IF part IS NOT NULL THEN
- rank_search := 25;
- rank_address := 11;
- ELSEIF postcode ~ '^[- :A-Z0-9]{6,}$' THEN
- rank_search := 21;
- rank_address := 11;
- END IF;
- END IF;
+ IF name is not null AND array_upper(akeys(name),1) > 1 THEN
+ default_language := get_country_language_code(country_code);
+ IF default_language IS NOT NULL THEN
+ IF name ? 'name' AND NOT name ? ('name:'||default_language) THEN
+ name := name || hstore(('name:'||default_language), (name -> 'name'));
+ ELSEIF name ? ('name:'||default_language) AND NOT name ? 'name' THEN
+ name := name || hstore('name', (name -> ('name:'||default_language)));
+ END IF;