diff --git a/etc/sphinx.conf.in b/etc/sphinx.conf.in index b1bb4fa1..cd3669e9 100644 --- a/etc/sphinx.conf.in +++ b/etc/sphinx.conf.in @@ -86,6 +86,14 @@ source att : base sql_attr_uint = mid } +source folder : base +{ + sql_query_pre = SET NAMES utf8 + sql_query = select id, folder_id, message_id, uid FROM folder_message + + sql_attr_uint = uid + sql_attr_uint = folder_id +} index main1 { @@ -198,6 +206,15 @@ index att1 ngram_chars = U+1100..U+2FA1F } +index folder1 +{ + source = folder + path = /var/piler/sphinx/folder1 + docinfo = extern + dict = keywords + min_prefix_len = 6 + min_word_len = 1 +} indexer { diff --git a/src/config.h b/src/config.h index e438a0ba..fc663be9 100644 --- a/src/config.h +++ b/src/config.h @@ -83,7 +83,7 @@ #define SQL_ARCHIVING_RULE_TABLE "archiving_rule" #define SQL_RETENTION_RULE_TABLE "retention_rule" #define SQL_FOLDER_RULE_TABLE "folder_rule" -#define SQL_FOLDER_EXTRA_TABLE "folder_extra" +#define SQL_FOLDER_USER_TABLE "folder_user" #define SQL_FOLDER_EMAIL_TABLE "folder_email" #define SQL_COUNTER_TABLE "counter" #define SQL_OPTION_TABLE "option" @@ -106,10 +106,10 @@ #define SQL_PREPARED_STMT_GET_ATTACHMENT_POINTER "SELECT `piler_id`, `attachment_id` FROM " SQL_ATTACHMENT_TABLE " WHERE id=?" #define SQL_PREPARED_STMT_QUERY_ATTACHMENT "SELECT `attachment_id`, `ptr` FROM " SQL_ATTACHMENT_TABLE " WHERE piler_id=? ORDER BY attachment_id ASC" #define SQL_PREPARED_STMT_GET_FOLDER_ID "SELECT `id` FROM " SQL_FOLDER_TABLE " WHERE `name`=? AND `parent_id`=?" -#define SQL_PREPARED_STMT_GET_FOLDER_EXTRA_ID "SELECT `id` FROM " SQL_FOLDER_EXTRA_TABLE " WHERE `name`=? AND `uid`=?" +#define SQL_PREPARED_STMT_GET_FOLDER_USER_ID "SELECT `id` FROM " SQL_FOLDER_USER_TABLE " WHERE `name`=? AND `uid`=?" #define SQL_PREPARED_STMT_GET_FOLDER_UID_BY_EMAIL "SELECT `uid` FROM " SQL_FOLDER_EMAIL_TABLE " WHERE `email`=?" #define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_TABLE "INSERT INTO `" SQL_FOLDER_TABLE "` (`name`, `parent_id`) VALUES(?,?)" -#define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_EXTRA_TABLE "INSERT INTO `" SQL_FOLDER_EXTRA_TABLE "` (`name`, `uid`) VALUES(?,?)" +#define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_USER_TABLE "INSERT INTO `" SQL_FOLDER_USER_TABLE "` (`name`, `uid`) VALUES(?,?)" #define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_EMAIL_TABLE "INSERT INTO `" SQL_FOLDER_EMAIL_TABLE "` (`email`) VALUES(?)" #define SQL_PREPARED_STMT_UPDATE_METADATA_REFERENCE "UPDATE " SQL_METADATA_TABLE " SET reference=? WHERE message_id=? AND reference=''" #define SQL_PREPARED_STMT_GET_GUI_IMPORT_JOBS "SELECT id, type, username, password, server FROM " SQL_IMPORT_TABLE " WHERE started=0 ORDER BY id LIMIT 0,1" diff --git a/src/folder.c b/src/folder.c index b980e84b..b8a2c745 100644 --- a/src/folder.c +++ b/src/folder.c @@ -62,7 +62,7 @@ void get_folder_uid_by_email(struct session_data *sdata, struct __data *data){ int get_folder_extra_id(struct session_data *sdata, struct __data *data, char *foldername){ int id=ERR_FOLDER; - if(prepare_sql_statement(sdata, &(data->stmt_get_folder_id), SQL_PREPARED_STMT_GET_FOLDER_EXTRA_ID) == ERR) return id; + if(prepare_sql_statement(sdata, &(data->stmt_get_folder_id), SQL_PREPARED_STMT_GET_FOLDER_USER_ID) == ERR) return id; p_bind_init(data); data->sql[data->pos] = foldername; data->type[data->pos] = TYPE_STRING; data->pos++; @@ -89,7 +89,7 @@ int add_new_folder_extra(struct session_data *sdata, struct __data *data, char * if(foldername == NULL) return id; - if(prepare_sql_statement(sdata, &(data->stmt_insert_into_folder_table), SQL_PREPARED_STMT_INSERT_INTO_FOLDER_EXTRA_TABLE) == ERR) return id; + if(prepare_sql_statement(sdata, &(data->stmt_insert_into_folder_table), SQL_PREPARED_STMT_INSERT_INTO_FOLDER_USER_TABLE) == ERR) return id; p_bind_init(data); data->sql[data->pos] = foldername; data->type[data->pos] = TYPE_STRING; data->pos++;