From 64f6aafeb38be7c383cd8ce99028c6d8de8bf39a Mon Sep 17 00:00:00 2001 From: SJ Date: Mon, 22 Sep 2014 11:13:55 +0200 Subject: [PATCH] sphinx fixes upgrading 2.1.x -> 2.2.x --- etc/sphinx.conf.in | 25 ++++--------------------- init.d/rc.searchd.in | 6 ++++++ webui/model/search/search.php | 9 +++++---- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/etc/sphinx.conf.in b/etc/sphinx.conf.in index bcd1aa7b..936687f7 100644 --- a/etc/sphinx.conf.in +++ b/etc/sphinx.conf.in @@ -59,9 +59,9 @@ source dailydelta : base source tag : base { sql_query_pre = SET NAMES utf8 - sql_query = SELECT `_id`, `id`, `uid`, `tag` FROM `tag` + sql_query = SELECT `_id`, `id` AS iid, `uid`, `tag` FROM `tag` - sql_attr_uint = id + sql_attr_uint = iid sql_attr_uint = uid } @@ -70,9 +70,9 @@ source tag : base source note : base { sql_query_pre = SET NAMES utf8 - sql_query = SELECT `_id`, `id`, `uid`, `note` FROM `note` + sql_query = SELECT `_id`, `id` AS iid, `uid`, `note` FROM `note` - sql_attr_uint = id + sql_attr_uint = iid sql_attr_uint = uid } @@ -83,8 +83,6 @@ index main1 source = main1 path = /var/piler/sphinx/main1 docinfo = extern - charset_type = utf-8 - enable_star = 1 min_prefix_len = 6 min_word_len = 1 #ngram_len = 1 @@ -96,8 +94,6 @@ index main2 source = main2 path = /var/piler/sphinx/main2 docinfo = extern - charset_type = utf-8 - enable_star = 1 min_prefix_len = 6 min_word_len = 1 #ngram_len = 1 @@ -109,8 +105,6 @@ index main3 source = main3 path = /var/piler/sphinx/main3 docinfo = extern - charset_type = utf-8 - enable_star = 1 min_prefix_len = 6 min_word_len = 1 #ngram_len = 1 @@ -122,8 +116,6 @@ index main4 source = main4 path = /var/piler/sphinx/main4 docinfo = extern - charset_type = utf-8 - enable_star = 1 min_prefix_len = 6 min_word_len = 1 #ngram_len = 1 @@ -135,8 +127,6 @@ index dailydelta1 source = dailydelta path = /var/piler/sphinx/dailydelta1 docinfo = extern - charset_type = utf-8 - enable_star = 1 min_prefix_len = 6 min_word_len = 1 #ngram_len = 1 @@ -148,8 +138,6 @@ index delta1 source = delta path = /var/piler/sphinx/delta1 docinfo = extern - charset_type = utf-8 - enable_star = 1 min_prefix_len = 6 min_word_len = 1 #ngram_len = 1 @@ -162,8 +150,6 @@ index tag1 source = tag path = /var/piler/sphinx/tag1 docinfo = extern - charset_type = utf-8 - enable_star = 1 min_prefix_len = 6 min_word_len = 1 #ngram_len = 1 @@ -176,8 +162,6 @@ index note1 source = note path = /var/piler/sphinx/note1 docinfo = extern - charset_type = utf-8 - enable_star = 1 min_prefix_len = 6 min_word_len = 1 #ngram_len = 1 @@ -206,5 +190,4 @@ searchd preopen_indexes = 1 unlink_old = 1 workers = threads # for RT to work - compat_sphinxql_magics = 0 } diff --git a/init.d/rc.searchd.in b/init.d/rc.searchd.in index fa03a90f..25476e24 100644 --- a/init.d/rc.searchd.in +++ b/init.d/rc.searchd.in @@ -20,6 +20,12 @@ PID_NUMBER=`test -f ${PID_FILE} && cat ${PID_FILE}` start() { echo "starting searchd . . ." + + if [ ! -d /var/run/piler ]; then + mkdir -p /var/run/piler + chown piler:piler /var/run/piler + fi + if [ `id -u` -eq 0 ]; then su piler -c searchd else diff --git a/webui/model/search/search.php b/webui/model/search/search.php index 094a6c7c..68a7ec02 100644 --- a/webui/model/search/search.php +++ b/webui/model/search/search.php @@ -417,10 +417,11 @@ class ModelSearchSearch extends Model { $s = $this->fixup_sphinx_operators($s); - $q = $this->sphx->query("SELECT id FROM $sphx_table WHERE uid=" . $session->get("uid") . " AND MATCH('@$field $s') "); + $q = $this->sphx->query("SELECT iid FROM $sphx_table WHERE uid=" . $session->get("uid") . " AND MATCH('@$field $s') "); + if(ENABLE_SYSLOG == 1) { syslog(LOG_INFO, "sql: " . $q->query); } foreach($q->rows as $a) { - $id_list .= "," . $a['id']; + $id_list .= "," . $a['iid']; } if($id_list) { $id_list = substr($id_list, 1, strlen($id_list)); } @@ -446,10 +447,10 @@ class ModelSearchSearch extends Model { } - $q = $this->db->query("SELECT id FROM " . TABLE_FOLDER_MESSAGE . " WHERE folder_id IN ($q)", $__folders); + $q = $this->db->query("SELECT iid FROM " . TABLE_FOLDER_MESSAGE . " WHERE folder_id IN ($q)", $__folders); foreach($q->rows as $a) { - $id_list .= "," . $a['id']; + $id_list .= "," . $a['iid']; } if($id_list) { $id_list = substr($id_list, 1, strlen($id_list)); }