首页 > 解决方案 > SphinxSearch - 索引器配置选项问题

问题描述

我使用 sphinx search 在我的 PostgreSQL 数据库中创建索引和搜索数据。

我有两个问题。

  1. 如果我运行命令

    /usr/bin/indexer --config /etc/sphinxsearch/sphinx.conf --rotate --all

我从“显示表格”中得到输出;

指数 类型
dist_title_de 分散式
word_title_de 当地的
word_titlestemmed_de 当地的
rt_title_de rt

但是如果我运行命令

/usr/bin/indexer --config /etc/sphinxsearch/sphinx_another_conf_file.conf --rotate --all

然后我在终端上得到相同的输出,但我没有在“显示表”上看到新的索引;似乎索引器中的“--config”选项不起作用,只有正确的名称是 sphinx.conf。这是有问题的,因为如果我想重新索引 sphinxsearch,我必须更改文件 sphinx.conf。


  1. 第二个问题是否可以在不删除旧索引的情况下“添加”新索引?目前我使用狮身人面像(每天):

但是现在,我想要这样的东西:

  1. 从 datasource1 获取新数据
  2. 索引数据源1
  3. 从datasource2获取新数据
  4. 索引datasource2(不删除索引datasource1)
  5. 在索引 datasource1 中搜索某些内容
  6. ……
  7. 获取新数据表单datasource8(不删除索引)
  8. 索引数据源8等

关于“不删除索引”,我的意思是,现在如果我使用主题顶部的命令,我会“丢失”我的索引并只获得新的索引(来自 sphinx.conf)。

我的 sphinx.conf(只有 1 个数据源):

source src_title_de
{
    type            = pgsql
    sql_host        = #######
    sql_user        = #######
    sql_pass        = #######
    sql_db          = #######
    sql_port        = 3306  # optional, default is 3306
    sql_query       = \
        SELECT id, group_id, (date_extraction::TIMESTAMP) AS date_extraction, title \
        FROM sphinx_test
    sql_ranged_throttle = 0
}

index word_title_de
{
source          = src_title_de
path            = /var/lib/sphinxsearch/data/word_title_de
docinfo         = extern
dict            = keywords
mlock           = 0
morphology      = none
stopwords       = /var/lib/sphinxsearch/data/stopwords.txt
wordforms       = /var/lib/sphinxsearch/data/wordforms_de.txt
min_word_len        = 1
}

index word_titlestemmed_de : word_title_de
{
    path            = /var/lib/sphinxsearch/data/word_titlestemmed_de
    morphology      = stem_en
}

index dist_title_de
{
type            = distributed
local           = word_title_de
local           = word_titlestemmed_de
agent           = localhost:9313:remote1
agent           = localhost:9314:remote2,remote3
agent_connect_timeout   = 1000
agent_query_timeout     = 3000
}

index rt_title_de
{
type            = rt
path            = /var/lib/sphinxsearch/data/rt_title_de
rt_field        = title
rt_field        = content
rt_attr_uint        = gid
}


indexer
{
mem_limit       = 128M
}

searchd
{
listen          = 9312:sphinx
listen          = 9306:mysql41
log         = /var/log/sphinxsearch/searchd.log
query_log       = /var/log/sphinxsearch/query.log
read_timeout        = 5
client_timeout      = 300
max_children        = 30
persistent_connections_limit    = 30
pid_file        = /var/run/sphinxsearch/searchd.pid
seamless_rotate     = 1
preopen_indexes     = 1
unlink_old      = 1
mva_updates_pool    = 1M
max_packet_size     = 8M
max_filters     = 256
max_filter_values   = 4096
max_batch_queries   = 32
workers         = threads # for RT to work
}

我的 8 个数据源的第二个文件与上面相同,在 'source src_title_de'、'index word_title_de'、'index word_titlestemmed_de'、'index rt_title_de' 上使用 CTRL+C CTRL+V 与另一个国家/地区并使用 'sql_query' 中的数据更改表.

标签: sphinx

解决方案


在您的第一个问题上,该--config选项仅适用于该indexer运行。即 --all 应该导致它索引(或尝试)索引该文件中提到的所有普通索引。

...但是当它发送信号以重新加载(--rotate)的作用时,searchd只是重新加载其当前配置文件,而不是您告诉的那个indexer

serachd使用新的配置文件,必须停止searchd,然后使用新的配置文件重新启动。

所以直接更改 sphinx.conf,而不是“第二个”文件。


Acully第二个问题是相同的答案......

所以sphinx.conf直接改变,而不是“第二个”文件。

即将您的新索引添加到sphinx.conf,用于indexer“构建”它。完成indexer后,它将告诉“重新加载”,这将导致searchd加载新的配置文件和刚刚构建的新索引。


推荐阅读