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

  * * * /usr/local/shell/test_t0.sh #每天凌晨3点半更新主索引
*/ * * * * /usr/local/shell/test_t0_delta.sh #每隔10分钟更新增量索引

Sphinx主索引和增量索引来实现索引实时更新的关键步骤的更多相关文章

  1. sphinx增量索引和主索引来实现索引的实时更新

    项目中文章的信息内容因为持续有新增,而文章总量的基数又比较大,所以做搜索的时候,用了主索引+增量索引这种方式来实现索引的实时更新. 实现原理: 1. 新建一张表,记录一下上一次已经创建好索引的最后一条 ...

  2. sphinx通过增量索引实现近实时更新

    一.sphinx增量索引实现近实时更新设置 数据库中的已有数据很大,又不断有新数据加入到数据库中,也希望能够检索到.全部重新建立索引很消耗资源,因为我们需要更新的数据相比较而言很少. 例如.原来的数据 ...

  3. sphinx 增量索引 实现近实时更新

    一.sphinx增量索引的设置   数据库中的已有数据很大,又不断有新数据加入到数据库中,也希望能够检索到.全部重新建立索引很消耗资源,因为我们需要更新的数据相比较而言很少.例如.原来的数据有几百万条 ...

  4. cassandra——可以预料的查询,如果你的查询条件有一个是根据索引查询,那其它非索引非主键字段,可以通过加一个ALLOW FILTERING来过滤实现

    cassandra的索引查询和排序 转自:http://zhaoyanblog.com/archives/499.html   cassandra的索引查询和排序 cassandra的查询虽然很弱,但 ...

  5. 视图view没有主键,但可以添加唯一索引

    视图没有主键,但可以加上唯一索引 大致可以这样理解:视图是张虚拟的表.视图所对应的数据不进行实际的存储,数据库中只存储视图的定义,对视图的数据进行操作时,系统根据视图的定义去操作与视图相关联的基本表. ...

  6. Oracle监控用户索引使用情况,删除无用索引

    监控当前业务用户索引 一段时间后查询从未被使用的索引,删除无用索引 停止监控索引 1. 监控当前用户所有索引 得到监控所有索引的语句: select 'alter index ' || index_n ...

  7. SQL 创建索引的作用以及如何创建索引

    SQL 创建索引的作用以及如何创建索引 SQL 创建索引的作用 一.使用索引的优点: 1.通过唯一性索引(unique)可确保数据的唯一性 2.加快数据的检索速度 3.加快表之间的连接 4.减少分组和 ...

  8. 索引优化原则及Oracle中索引总结

    索引建立原则 确定针对该表的操作是大量的查询操作还是大量的增删改操作. 尝试建立索引来帮助特定的查询.检查自己的sql语句,为那些频繁在where子句中出现的字段建立索引. where语句中不得不对查 ...

  9. Elasticsearch 关键字:索引,类型,字段,索引状态,mapping,文档

    1. 索引(_index)索引:说的就是数据库的名字.我这个说法是对应到咱经常使用的数据库. 结合es的插件 head 来看. 可以看到,我这个地方,就有这么几个索引,索引就是数据库,后面是这个数据库 ...

随机推荐

  1. mariadb 压缩包gz安装方式

    1.解压安装包tar -zxvf mariadb-5.5.56-linux-x86_64.tar.gz 2.cd support-filescp my-small.cnf /etc/my.cnf 2. ...

  2. eclipse集成dorado5插件

    dorado5最好使用jdk1.6 32位,与eclipse j2ee indigo版本兼容最好.其他eclipse版本貌似view编辑时按钮点击事件不生效... 现附上安装包链接(均为官方版本): ...

  3. Hello English Again

    Currently, I just want to write something in English.Maybe I just want to review my Egnlish knowledg ...

  4. 反射、Attribute

    1.发射是对类或者对象,查看其类内部的构造. 2.类的组成:属性(PropertyInfo).方法(MethodInfo).字段(FiedInfo).构造函数(ConstructorInfo).事件( ...

  5. 分享调用Java private方法

    上周在修复bug时,发现Java类中某方法是private,且类中没有用到,第一感觉是方法多余.其实通过分析,发现原来Native Code会通过JNI调到此方法.这也给自己启发,平时做Code re ...

  6. Ubuntu14.04 设置wifi热点

    Ubuntu14.04 设置wifi热点 $ sudo add-apt-repository ppa:nilarimogard/webupd8 $ sudo apt-get update $ sudo ...

  7. 利用TPC-H为MYSQL生成数据

    ## 利用TPC-H为MYSQL生成数据 导言 这篇文章是看了joyee写的TPC-H数据导入MySQL教程以及另一篇网上的MySQL TPCH测试工具简要手册 后写的,有些内容是完全转载自以上两篇文 ...

  8. Problem : 1202 ( The calculation of GPA )

    Losers always whine about their best. Winners go home and fuck the prom queen. 很操蛋却非常有意思的题目,注意变量的类型, ...

  9. Git分支(2/5) -- Fast Forward 合并

    快捷操作: 切换并创建分支: git checkout -b 分支名. git checkout -b some-change 然后我打开某个文件(index.html)修改一下标题. Commit之 ...

  10. js 显示数字不断增加

    一个小小的函数,很容易看懂,就不过多解释了,只为下次用时直接用就ok了... function countUp(count) { var div_by = 100, speed = Math.roun ...