sphinx (coreseek)——3、区段查询 与 增量索引实例
首先本文测试数据100多万的域名的wwwtitle 信息 检索数据:
- 首先建立临时表格:
CREATE TABLE `sph_counter` (
`index_id` tinyint(1) NOT NULL,
`max_id` int(11) NOT NULL,
PRIMARY KEY (`index_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
- csft.complex.conf 文件修改配置:
#增量数据索引 区段查询 合并为一个文件实现 测试 配置文件
#数据源
source src
{
# data source type. mandatory, no default value
# known types are mysql, pgsql, mssql, xmlpipe, xmlpipe2, odbc
type = mysql #####################################################################
## SQL settings (for 'mysql' and 'pgsql' types)
##################################################################### # some straightforward parameters for SQL source types
sql_host = localhost
sql_user = root
sql_pass = 201671zhuang
sql_db = whomx
sql_port = # optional, default is
sql_query_pre = SET NAMES utf8
sql_query_pre = SET SESSION query_cache_type=OFF
sql_query_pre = REPLACE INTO sph_counter SELECT , MAX(id) FROM mx_domain_wwwinfo
#分次查询数据,不要一次将全部数据取
sql_query_range = SELECT MIN(id), (SELECT max_id FROM sph_counter WHERE index_id = ) FROM mx_domain_wwwinfo
#每一次的 数据条数量
sql_range_step =
sql_query = \
SELECT * \
FROM mx_domain_wwwinfo \
WHERE id>=$start AND id<=$end
sql_query_info = SELECT * FROM mx_domain_wwwinfo WHERE id=$id
}
# 表示增量数据源
source moresrc : src
{
sql_query_pre = SET NAMES utf8
sql_query_pre = SET SESSION query_cache_type=OFF
#增量索引实现
sql_query_range = SELECT (SELECT max_id FROM sph_counter WHERE index_id=),MAX(id) from mx_domain_wwwinfo
sql_range_step =
sql_query = \
SELECT * \
FROM mx_domain_wwwinfo \
WHERE id>=$start AND id<=$end
sql_query_post = \
REPLACE INTO sph_counter SELECT ,MAX(id) FROM mx_domain_wwwinfo
#获取数据后,改写sph_counter增量索引计数表中的数据
} #其他配置参照以前
- 更新主索引
root@timeless-HP-Pavilion-g4-Notebook-PC:/usr/local/coreseek/bin# /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/csft.complex.conf -all --rotate
Coreseek Fulltext 4.1 [ Sphinx 2.0.-dev (r2922)]
Copyright (c) -,
Beijing Choice Software Technologies Inc (http://www.coreseek.com) using config file '/usr/local/coreseek/etc/csft.complex.conf'...
indexing index 'src'...
WARNING: Attribute count is : switching to none docinfo
collected docs, 117.1 MB
sorted 20.5 Mhits, 100.0% done
total docs, bytes
total 39.557 sec, bytes/sec, 37941.06 docs/sec
indexing index 'moresrc'...
WARNING: Attribute count is : switching to none docinfo
collected docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total docs, bytes
total 0.001 sec, bytes/sec, 632.51 docs/sec
total reads, 0.047 sec, 3240.3 kb/call avg, 1.2 msec/call avg
total writes, 0.216 sec, 834.8 kb/call avg, 0.8 msec/call avg
rotating indices: succesfully sent SIGHUP to searchd (pid=).
- 数据库mx_doimain_wwwinfo表格添加测试数据。更新增量索引
root@timeless-HP-Pavilion-g4-Notebook-PC:/usr/local/coreseek/bin# /usr/local/coreseek/bin/indexer moresrc -c /usr/local/coreseek/etc/csft.complex.conf --rotate
Coreseek Fulltext 4.1 [ Sphinx 2.0.-dev (r2922)]
Copyright (c) -,
Beijing Choice Software Technologies Inc (http://www.coreseek.com) using config file '/usr/local/coreseek/etc/csft.complex.conf'...
indexing index 'moresrc'...
WARNING: Attribute count is : switching to none docinfo
collected docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total docs, bytes
total 0.013 sec, bytes/sec, 74.83 docs/sec
total reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
rotating indices: succesfully sent SIGHUP to searchd (pid=).
- 合并增量索引到主索引
root@timeless-HP-Pavilion-g4-Notebook-PC:/usr/local/coreseek/bin# /usr/local/coreseek/bin/indexer --merge src moresrc -c /usr/local/coreseek/etc/csft.complex.conf --rotate
Coreseek Fulltext 4.1 [ Sphinx 2.0.-dev (r2922)]
Copyright (c) -,
Beijing Choice Software Technologies Inc (http://www.coreseek.com) using config file '/usr/local/coreseek/etc/csft.complex.conf'...
read 11.5 of 11.5 MB, 100.0% done
merged 2268.5 Kwords
merged in 2.724 sec
total reads, 0.075 sec, 1.5 kb/call avg, 0.0 msec/call avg
total writes, 0.110 sec, 253.4 kb/call avg, 0.2 msec/call avg
rotating indices: succesfully sent SIGHUP to searchd (pid=).
- 测试 增量索引
root@timeless-HP-Pavilion-g4-Notebook-PC:/usr/local/coreseek/bin# ./search -c /usr/local/coreseek/etc/csft.complex.conf 济南Coreseek Fulltext 4.1 [ Sphinx 2.0.-dev (r2922)]
Copyright (c) -,
Beijing Choice Software Technologies Inc (http://www.coreseek.com) using config file '/usr/local/coreseek/etc/csft.complex.conf'...
index 'src': query '济南 ': returned matches of total in 0.001 sec displaying matches:
. document=, weight=
id=
domain_id=
title=?????????????,??????,??????,?????????????????????????????????????,??????,??????,????,????,??????,??????,??????,??????,????????,????,??????,??????,??????,??????,????????,????????,?????????,?????????
addtime=
. document=, weight=
id=
domain_id=
title=??--??????,?????,????????,????????,??????,??????,?????,?????,???,?????,?????,?????,?????,????,????,??????,??????,??????,?????,?????,?????,???,???????,
addtime=
. document=, weight=
id=
domain_id=
title=???????-???.??.???.???????/?????/?????/?????????/?????/?????/???? ????? ????? ????? ????? ????? ????? ??POS??? ????? ????? ????? ??POS?
addtime=
. document=, weight=
id=
domain_id=
title=???????-???.??.???.???????/?????/?????/?????????/?????/?????/???? ????? ????? ????? ????? ????? ????? ??POS??? ????? ????? ????? ??POS?
addtime=
. document=, weight=
id=
domain_id=
title=?????? - ???? | ????? | ????? | ?????? | ?????? | ?????? | ?????? | ?????? | ?????? | ?????? | ?????? | ?????? | ?????? | ??????
addtime=
. document=, weight=
id=
domain_id=
title=????????|????????|?????????|?????????|??????|?????|????????????????|????????|?????????|?????????|??????|?????|????????
addtime=
. document=, weight=
id=
domain_id=
title=???????????????????????????????????????????????????????????????????????????????????????????????????????
addtime=
. document=, weight=
id=
domain_id=
title=????|??????|????????|??????|??????|??????|??????|??????|??????|??????|??????-????????
addtime=
. document=, weight=
id=
domain_id=
title=????????????????????????????????????????????????????????????????????
addtime=
. document=, weight=
id=
domain_id=
title=??????|??????|??SKF??|??NSK??|??FAG??|??NTN??|??KOYO??|??TIMKEN??|??FAG??|????|????????|????????|??????|-??
addtime=
. document=, weight=
id=
domain_id=
title=???????|??????????|???????|??????????|??????|???????|?????????|????????|?????????|???????|??????????
addtime=
. document=, weight=
id=
domain_id=
title=???? ?????? ?????? ?????? ????? ?????? ???? ???? ?????? ???? ??????
addtime=
. document=, weight=
id=
domain_id=
title=??????|????|?????|?????????|???????????|??????|??????|????|?????|?????|?????|?????
addtime=
. document=, weight=
id=
domain_id=
title=??????????????????????????????????????????????????????????????????????????????_??????????????
addtime=
. document=, weight=
id=
domain_id=
title=?????????????????????????????????????????????????????????????????????????_??????????????
addtime=
. document=, weight=
id=
domain_id=
title=????????????????????????????????????????????????????????????????????????????_??????????????
addtime=
. document=, weight=
id=
domain_id=
title=??????|??????|??????|??????|??????|?????|??????|????????|???????????|????????????|???--
addtime=
. document=, weight=
id=
domain_id=
title=????????? ???????????? ??????? ?????????? ??????? ??????? ????????? ??????? ??????? ???????_?????????
addtime=
. document=, weight=
id=
domain_id=
title=????-|??????|??????????????|????????|???????|??????|????T1|????T3|????T6|????U8
addtime=
. document=, weight=
id=
domain_id=
title=????|?????|?????|?????|?????|?????|?????|?????|????|??????????
addtime= words:
#起作用
1. '济南': 11041 documents, 22216 hits index 'moresrc': query '济南 ': returned 1 matches of 1 total in 0.000 sec displaying matches:
1. document=1501042, weight=1500
id=1501042
domain_id=4
title=???? ??
addtime= words:
1. '济南': 1 documents, 2 hits
增量索引起作用
sphinx (coreseek)——3、区段查询 与 增量索引实例的更多相关文章
- Coreseek:区段查询及增量索引取代实时索引
1.区段查询 索引系统须要通过主查询来获取所有的文档信息,一种简单的实现是将整个表的数据读入内存,可是这可能导致整个表被锁定并使得其它操作被阻止(比如:在MyISAM格式上的INSERT操作),同一时 ...
- Coreseek:部门查询和增量索引代替实时索引
1.行业调查 索引系统需要通过主查询来获取所有的文档信息,一个简单的实现是整个表的数据到内存,但是这可能会导致整个表被锁定,并且使其它操作被阻止(例如:在MyISAM格款式上INSERT操作).同时, ...
- 【PHP高效搜索专题(2)】sphinx&coreseek在PHP程序中的应用实例
PHP可以通过三种途径来调用sphinx 通过Sphinx官方提供的API接口(接口有Python,Java,Php三种版本) 通过安装SphinxSE,然后创建一个中介sphinxSE类型的表,再通 ...
- coreseek增量索引
1.在多数情况下,因为Coreseek索引速度高达10MB/s,所以只需要创建一个索引源即可满足需求,但是在数据量随时激增的大型应用中(如SNS.评论系统等),单一的索引源将会给indexer造成极大 ...
- sphinx增量索引
首先建立一个计数表,保存数据表的最新记录ID CREATE TABLE `sph_counter` ( `id` int(11) unsigned NOT NULL, `max_id` int(1 ...
- sphinx增量索引使用
sphinx在使用过程中如果表的数据量很大,新增加的内容在sphinx索引没有重建之前都是搜索不到的. 这时可以通过建立sphinx增量索引,通过定时更新增量索引,合并主索引的方式,来实现伪实时更新. ...
- sphinx (coreseek)——2、区段查询实例
首先需要知道区段查询的定义: 索引系统需要通过主查询来获取全部的文档信息,一种简单的实现是将整个表的数据读入内存,但是这可能导致整个表被锁定并使得其他操作被阻止(例如:在MyISAM格式上的INSER ...
- sphinx(coreseek)——1、增量索引
首先介绍一下 CoreSeek/Sphinx的发布包 indexer: 用于创建全文索引; search: 一个简单的命令行(CLI) 的测试程序,用于测试全文索引; search ...
- sphinx增量索引和主索引来实现索引的实时更新
项目中文章的信息内容因为持续有新增,而文章总量的基数又比较大,所以做搜索的时候,用了主索引+增量索引这种方式来实现索引的实时更新. 实现原理: 1. 新建一张表,记录一下上一次已经创建好索引的最后一条 ...
随机推荐
- git submodule的操作
对于有submodule的库,检出的方法是: git clone https://github.com/BelledonneCommunications/linphone-android.git -- ...
- kickStart脚本
kickstart是什么 许多系统管理员宁愿使用自动化的安装方法来安装红帽企业 Linux.为了满足这种需要,红帽创建了kickstart安装方法.使用kickstart,系统管理员可以 ...
- Inheritance - SGU 129(线段与多边形相交的长度)
题目大意:给一个凸多边形(点不是按顺序给的),然后计算给出的线段在这个凸多边形里面的长度,如果在边界不计算. 分析:WA2..WA3...WA4..WA11...WA的无话可说,总之细节一定考虑清楚, ...
- XML文件操作指南
一.XML简介 XML的全名是eXtensible Markup Language(可以扩展的标记语言),它的语法类似HTML,都是用标签来描述数据.HTML的标签是固定的,我们只能使用.不能修改: ...
- SQL profile纵览(10g)
第一篇:介绍 10g开始,查询优化器(Query optimizer)扩展成自动调整优化器(Automatic Tuning Optimizer).也就是扩展了功能.此时,我们就可以让 ...
- 编译LOADCEPC.EXE程序
1.安装编译工具 安装MSVC152路径C:/MSVC; 安装MASM611可以自己指定E:/MASM611; 命令行编译 相关文件配置 修改setupen2.bat 如下: :PATH_DONE s ...
- android RelativeLayout 内容居中解决办法
android RelativeLayout 内容居中解决办法: 使用Linearlayout本来利用父控件的gravity属性是很好解决的.但是对应RelativeLayout虽然有 gravi ...
- FastDFS问题汇总
问题1: 增加分组后,新的storge不可用. 增加一个分组group2,发现上传文件失败.在group2中的storage中使用netstat -anp|grep fdfs,发现端口状态为CLOSE ...
- xslt中的常用函数
在我们制作标签的时候经常要使用到一些xslt的知识,以下整理了常用的xslt函数供大家使用. 常用字符串函数: contains('Welcome','e'):字符串包含,包含:true,不包含:fa ...
- java获取计算机硬件参数
public class HardWareUtils { /** * * 获取主板序列号 * * * * @return */ public static String g ...