• Sphinx主索引和增量索引来实现索引实时更新的关键步骤


    1.配置csft.conf文件 

    vim /etc/csft.conf

    #
    # Minimal Sphinx configuration sample (clean, simple, functional)
    #
    
    source test_t0
    {
        type                    = mysql
    
        sql_host                = localhost
        sql_user                = root
        sql_pass                = 123123
        sql_db                    = test
        sql_port                = 3306    # optional, default is 3306
            sql_query_pre                           = SET NAMES utf8
        sql_query_pre                           = REPLACE INTO count_t0 select 1,max(id) from t0
        sql_query                = 
            SELECT id, description, name, age 
            FROM t0 WHERE id <= (SELECT max_id FROM count_t0 where c_id=1 )
    
        sql_attr_uint            = age
            #sql_attr_timestamp        = date_added
    
            #sql_query_info            = SELECT * FROM documents WHERE id=$id
    }
    
    source test_t0_delta:test_t0
    {
        sql_query_pre        = SET NAMES utf8
        sql_query_pre        =
        sql_query                = 
            SELECT id, description, name, age 
            FROM t0 WHERE id > (SELECT max_id FROM count_t0 where c_id=1 )
    }
    
    index test_t0
    {
        source                    = test_t0
        path                    = /usr/local/coreseek/var/data/test_t0
        docinfo                    = extern
            charset_dictpath                        = /usr/local/mmseg/etc/
        charset_type                    = zh_cn.utf-8
    }
    
    index test_t0_delta:test_t0
    {
        source                    = test_t0_delta
        path                    = /usr/local/coreseek/var/data/test_t0_delta
        docinfo                    = extern
            charset_dictpath                        = /usr/local/mmseg/etc/
        charset_type                    = zh_cn.utf-8
    }
    
    indexer
    {
        mem_limit                = 512M
    }
    
    
    searchd
    {
        port                    = 9312
        log                        = /usr/local/coreseek/var/log/searchd.log
        query_log                = /usr/local/coreseek/var/log/query.log
        read_timeout            = 5
        max_children            = 30
        pid_file                = /usr/local/coreseek/var/log/searchd.pid
        max_matches                = 1000
        seamless_rotate            = 1
        preopen_indexes            = 0
        unlink_old                = 1
    }

     2.重新生成主索引的shell脚本文件

    cd /usr/local/shell

    vim test_t0.sh

    #!/bin/sh
    /usr/local/coreseek/bin/searchd -c /etc/csft.conf --stop #停止searchd
    /usr/local/coreseek/bin/indexer -c /etc/csft.conf test_t0 #生成索引
    /usr/local/coreseek/bin/searchd -c /etc/csft.conf #启动searchd

    chmod 755 test_t0.sh

    3.重新生成增量索引的shell脚本文件

    cd /usr/local/shell

    vim test_t0_delta.sh

    #!/bin/sh
    /usr/local/coreseek/bin/searchd -c /etc/csft.conf --stop
    /usr/local/coreseek/bin/indexer -c /etc/csft.conf test_t0_delta

    /usr/local/coreseek/bin/searchd -c /etc/csft.conf #启动searchd

    chmod 755 test_t0_delta.sh

    4.添加到定时任务

    crontab -e

    30 3 * * * /usr/local/shell/test_t0.sh #每天凌晨3点半更新主索引
    */10 * * * * /usr/local/shell/test_t0_delta.sh #每隔10分钟更新增量索引
  • 相关阅读:
    多尺度双边滤波及基于小波变换的非线性扩散
    yum安装CentOS7+nginx+php7.3+mysql5.7
    python学习之特殊魔法__getattr__,__getattribute__
    python学习之特殊魔法__get__,__set__,__delete__
    python学习之装饰器
    python学习之私有属性
    python学习之包装与授权
    python学习之生成器(generator)
    python学习之运用特殊方法,定制类
    python学习之创建迭代器对象
  • 原文地址:https://www.cnblogs.com/freelyflying/p/6701991.html
Copyright © 2020-2023  润新知