sphinx/coreseek配置postgresql增量索引

新创建一个表保存最大id,区分主索引和增量索引 # 搜索索引相关 CREATE TABLE index_delta ( id SERIAL PRIMARY KEY, max_id integer ); INSERT INTO index_delta (id, max_id) VALUES (1, 0); 我这里直接插入数据,后边配置的时候直接使用update就行了,不然太麻烦。 配置文件;先大体测试了一下,应该没什么问题了,安装的3.2版本的coreseek,好多功能没有,不过够用了,先布置到线上看看效果
source main
{
        type                    = pgsql

        sql_host                = localhost
        sql_user                = pgsql
        sql_pass                =
        sql_db                  = bt
        sql_port                = 5432  # optional, default is 3306

        sql_query_pre = SET NAMES 'UTF8'
        sql_query_pre = UPDATE index_delta set id=1, max_id=max FROM (SELECT MAX(id) AS max FROM hash) AS foo;

        sql_query_range = SELECT MIN(id),MAX(id) FROM hash
        sql_range_step = 1000
        sql_query = SELECT id, hash, extract('epoch' FROM insert_time)::int AS date_added, name, files \
                FROM hash WHERE id>=$start AND id<=$end AND id<=(select max_id from index_delta )

        # sql_attr_uint         = hash
        sql_attr_timestamp      = date_added
        # sql_field_string = name
        # sql_field_string = files

        sql_query_info_pre      = SET NAMES utf8
        sql_query_info          = SELECT * FROM hash WHERE id=$id
}

source delta : main
{
    sql_query_pre = SET NAMES 'UTF8'
    sql_query_range = SELECT a.min_id, b.max_id FROM (SELECT MAX(id) AS max_id FROM hash) AS b, \
                (SELECT max_id AS min_id FROM index_delta) AS a
    sql_range_step = 1000
    sql_query = SELECT id, hash, extract('epoch' FROM insert_time)::int AS date_added, name, files \
                FROM hash WHERE id>(select max_id from index_delta ) AND id>=$start AND id<=$end
}

index main
{
        source                  = main
        path                    = /usr/local/coreseek/var/data/main
        docinfo                 = extern
        # charset_type          = sbcs

        # rt_field = name
        # rt_field = files

        mlock            = 0
        morphology        = none
        min_word_len        = 1
        html_strip = 0
        charset_dictpath        = /usr/local/mmseg3/etc/
        charset_type            = zh_cn.utf-8
        ngram_len=0
}

index delta : main
{
        source = delta
        path = /usr/local/coreseek/var/data/delta
        docinfo = extern

        mlock            = 0
        morphology        = none
        min_word_len        = 1
        html_strip = 0
        charset_dictpath        = /usr/local/mmseg3/etc/
        charset_type            = zh_cn.utf-8
        ngram_len=0

}


indexer
{
        mem_limit               = 64M
}
index main
{
        source                  = main
        path                    = /usr/local/coreseek/var/data/main
        docinfo                 = extern
        # charset_type          = sbcs

        # rt_field = name
        # rt_field = files

        mlock            = 0
        morphology        = none
        min_word_len        = 1
        html_strip = 0
        charset_dictpath        = /usr/local/mmseg3/etc/
        charset_type            = zh_cn.utf-8
        ngram_len=0
}

index delta : main
{
        source = delta
        path = /usr/local/coreseek/var/data/delta
        docinfo = extern

        mlock            = 0
        morphology        = none
        min_word_len        = 1
        html_strip = 0
        charset_dictpath        = /usr/local/mmseg3/etc/
        charset_type            = zh_cn.utf-8
        ngram_len=0

}


indexer
{
        mem_limit               = 64M
}
sphinx自带python的api接口,在源代码的api目录里,python api/test.py MP4,可以搜索MP4的关键字,测试一下可以用。 看了一眼sphinx.py,就是请求的listen端口。这个后边慢慢研究一下。 >>> import sphinxapi >>> c = sphinxapi.SphinxClient() >>> q = c.Query('world')

上一篇:
下一篇:

相关文章:

Categories: 博客记录

0 Responses so far.

Leave a Reply