zoukankan      html  css  js  c++  java
  • 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分钟更新增量索引
  • 相关阅读:
    08.设计模式,和ES6let
    H5之本地存储
    07..前后台交互,设计模式
    查询出总数集合
    06.JSON+ajax+跨域+onde 环境搭建 笔记
    05 this 在不同环境下的指向 和正则
    04学习 JS 作用域 继承 闭包
    技术盛宴 | 从实战浅析运营商云资源池—解析流量模型
    从实战浅析运营商云资源池网络—技术的抉择
    ovn-sbctl
  • 原文地址:https://www.cnblogs.com/freelyflying/p/6701991.html
Copyright © 2011-2022 走看看