Skip to content
Permalink
Browse files

rebuild GNS search index; fixes #175

  • Loading branch information...
following5 committed Aug 5, 2015
1 parent 67a60a1 commit 024928940d95fa975a7d4b8c7c15b1f3c447e979
Showing with 24 additions and 3 deletions.
  1. +22 −0 bin/dbsv-update.php
  2. +0 −2 htdocs/doc/sql/tables/gns_search.sql
  3. +2 −1 htdocs/util2/gns/mksearchindex.php
@@ -20,6 +20,7 @@
if (!isset($opt['rootpath']))
$opt['rootpath'] = dirname(__FILE__) . '/../htdocs/';
require_once($opt['rootpath'] . 'lib2/cli.inc.php');
require_once($opt['rootpath'] . 'lib2/search/search.inc.php');
if (!sql_field_exists('cache_attrib','gc_id'))
{
@@ -481,6 +482,27 @@ function dbv_127() // fix name of Dessau-Köthen
sql("UPDATE `cache_location` SET `adm4`='Köthen' WHERE `code4`='DEE15'");
}
function dbv_128() // see util2/gns/mksearchindex.php; fix for #175/3
{
sql('DELETE FROM `gns_search`');
if (sql_field_exists('gns_search','id'))
sql("ALTER TABLE `gns_search` DROP COLUMN `id`");
// unused, does not make sense; will also drop primary index
$rs = sql("SELECT `uni`, `full_name_nd` FROM `gns_locations` WHERE `dsg` LIKE 'PPL%'");
while ($r = sql_fetch_array($rs))
{
$text = search_text2sort($r['full_name_nd'], true);
if (preg_match("/[a-z]+/", $text))
{
$simpletext = search_text2simple($text);
sql("INSERT INTO `gns_search` (`uni_id`, `sort`, `simple`, `simplehash`) VALUES ('&1', '&2', '&3', '&4')", $r['uni'], $text, $simpletext, sprintf("%u", crc32($simpletext)));
}
}
mysql_free_result($rs);
}
// When adding new mutations, take care that they behave well if run multiple
// times. This improves robustness of database versioning.
//
@@ -1,11 +1,9 @@
SET NAMES 'utf8';
DROP TABLE IF EXISTS `gns_search`;
CREATE TABLE `gns_search` (
`id` int(11) NOT NULL auto_increment,
`uni_id` int(11) NOT NULL default '0',
`sort` varchar(255) NOT NULL,
`simple` varchar(255) NOT NULL,
`simplehash` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `simplehash` (`simplehash`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='static content' ;
@@ -24,13 +24,14 @@
{
$simpletexts = search_text2sort($r['full_name_nd'], true);
$simpletextsarray = explode_multi($simpletexts, ' -/,');
// ^^ This should be obsolete, as search_text2sort() removes all non-a..z chars.
foreach ($simpletextsarray AS $text)
{
if ($text != '')
{
if (nonalpha($text))
die($r['uni'] . ' ' . $text . "\n");
die($r['uni'] . ' ' . $text . "\n"); // obsolete for the same reason as above
$simpletext = search_text2simple($text);

0 comments on commit 0249289

Please sign in to comment.
You can’t perform that action at this time.