+if ($aCMDResult['create-country-names'] || $aCMDResult['all']) {
+ echo 'Creating search index for default country names';
+ $bDidSomething = true;
+
+ pgsqlRunScript("select getorcreate_country(make_standard_name('uk'), 'gb')");
+ pgsqlRunScript("select getorcreate_country(make_standard_name('united states'), 'us')");
+ pgsqlRunScript("select count(*) from (select getorcreate_country(make_standard_name(country_code), country_code) from country_name where country_code is not null) as x");
+ pgsqlRunScript("select count(*) from (select getorcreate_country(make_standard_name(name->'name'), country_code) from country_name where name ? 'name') as x");
+
+ $sSQL = 'select count(*) from (select getorcreate_country(make_standard_name(v), country_code) from (select country_code, skeys(name) as k, svals(name) as v from country_name) x where k ';
+ if (CONST_Languages) {
+ $sSQL .= 'in ';
+ $sDelim = '(';
+ foreach (explode(',', CONST_Languages) as $sLang) {
+ $sSQL .= $sDelim."'name:$sLang'";
+ $sDelim = ',';
+ }
+ $sSQL .= ')';
+ } else {
+ // all include all simple name tags
+ $sSQL .= "like 'name:%'";
+ }
+ $sSQL .= ') v';
+ pgsqlRunScript($sSQL);
+}
+