0

我使用本教程将原始 sphinx 索引转换为实时索引:http ://www.ivinco.com/blog/converting-sphinx-original-indexes-to-real-time-indexes/

我改变了我的 sphinx.conf:

source movies_dev
{
    type                            = mysql

    sql_host                        = localhost
    sql_user                        = ********
    sql_pass                        = ********
    sql_db                          = ********
    sql_sock                        = /var/run/mysqld/mysqld.sock
    sql_port                        = 3306

    sql_query                       = \
            SELECT \
                    CRC32(movie_id) AS id, movie_id, format_id, active, year, title \
            FROM \
                    movie;
    sql_attr_uint                   = format_id
    sql_attr_uint                   = active
    sql_attr_uint                   = year
    sql_field_string                   = movie_id
    sql_field_string                   = title

    sql_query_info          = SELECT * FROM movie WHERE CRC32(movie_id)=$id
    sql_query_pre = SET NAMES utf8
}

index movies_dev
{
    source                  = movies_dev
    path                    = /var/data/sphinx/movies_dev
    morphology              = stem_en
    enable_star = 1
    min_word_len            = 3
    min_prefix_len          = 0
    min_infix_len           = 3
    charset_type = utf-8
    charset_table   = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F, U+DC->U+FC, U+C4->U+E4, U+D6->U+F6, U+DF, U+E4, U+F6, U+FC
}

index rt_movies_dev
{
    type                    = rt
    rt_mem_limit            = 32M

    path                    = /var/data/sphinx/rt_movies_dev
    charset_type            = utf-8

    rt_field                   = movie_id
    rt_field                   = title
    rt_attr_uint                   = format_id
    rt_attr_uint                   = year
    rt_attr_uint                   = active
}

source attach_movies_dev
{
    type                    = mysql

    sql_host                = localhost
    sql_user                = ********
    sql_pass                = ********
    sql_db                  = ********

    sql_query               = SELECT 1 FROM rt_movies_dev
    sql_query_post          = ATTACH INDEX movies_dev TO RTINDEX rt_movies_dev
}

index attach_movies_dev
{
    source                  = attach_movies_dev
    path                    = /var/data/sphinx/attach_movies_dev
    docinfo                 = extern
    charset_type            = utf-8
}

我创建了“rt_movies_dev”表:

SET NAMES utf8;
SET foreign_key_checks = 0;
SET time_zone = '+01:00';
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';

DROP TABLE IF EXISTS `rt_movies_dev`;
CREATE TABLE `rt_movies_dev` (
  `movie_id` varchar(20) NOT NULL,
  `format_id` int(10) NOT NULL,
  `title` varchar(255) NOT NULL,
  `year` int(20) DEFAULT NULL,
  `active` tinyint(1) NOT NULL,
PRIMARY KEY (`movie_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

之后,我运行这三个命令:

root@server:~# /usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/sphinx.conf;
root@server:~# /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf movies_dev --rotate;
root@server:~# /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf attach_movies_dev;

前两个命令后没有错误(除了教程中的警告)。但是最后一个命令抛出了这个:

ERROR: index 'attach_movies_dev': No fields in schema - will not index.

我不知道错误到底是什么意思,我找不到任何有用的东西。你能说有什么问题吗?我被困在这里。

4

1 回答 1

0

首先 attach_movies_dev 源,连接到 SPHINX,而不是 mysql。所以不需要mysql表。

您只是使用索引器来调用 SphinxQL 命令。

但是从我所看到的尝试索引附加索引,总是会导致错误,因为 RT 索引本身必须为空(因此可以附加磁盘索引!)

因此,请更改您的附加索引以连接到 searchd。它应该工作得更好。可能是一个空的 RT 索引,没关系,索引器只会创建一个空索引,但重要的是它仍然会运行 _post 命令。这就是索引存在的全部原因!

另请注意,您的磁盘索引和 RT 索引具有不同的字段,在您的磁盘索引中,您有两个 sql_field_string,它们同时创建属性和字段。因此,您的 RT 索引应该包含两个要匹配的字符串属性(而不仅仅是字段)。

于 2013-10-27T22:06:12.727 回答