在sphinx中应用复杂过滤条件
CREATE TABLE `t_test_filter` (
`Fcommodity_id` bigint(20) unsigned NOT NULL DEFAULT '0',
` FUserId` int(10) unsigned NOT NULL DEFAULT '0',
` FUserName` varchar(32) NOT NULL DEFAULT '',
`Fshopid` bigint(20) unsigned NOT NULL DEFAULT '0',
`Ftitle` varchar(60) NOT NULL DEFAULT '',
`FProperty` int(10) unsigned NOT NULL DEFAULT '0',
`FTime` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`Fcommodity_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
`id` bigint(20) unsigned NOT NULL,
`weight` int(11) DEFAULT '1',
`query` varchar(3072) NOT NULL,
`total_found` int(11) DEFAULT '0',
`total_match` int(11) DEFAULT '0',
`query_time` int(11) DEFAULT '0',
` FUserId` int(10) unsigned DEFAULT '0',
`Fshopid` bigint(20) unsigned NOT NULL DEFAULT '0',
`FProperty` int(10) unsigned NOT NULL DEFAULT '0',
`FTime` int(10) unsigned NOT NULL DEFAULT '0',
KEY `query` (`query`(1536))
) ENGINE=SPHINX DEFAULT CHARSET=gbk CONNECTION='sphinx://localhost:9412'
insert into t_test_filter values(4567,123,"test qq nick", 1234567,"title name",2324354,9876);
insert into t_test_filter values(2,34,"nick name", 4545,"title name",67,40);
insert into t_test_filter values(66,55,"test3 qq3 nick3", 22,"title3 name3 ",88,77);
insert into t_test_filter values(767,234,"test3 qq nick", 3433,"title3 name3 ",342342,89340);
insert into t_test_filter values(4545,123,"test qq nick", 1234567,"title name",2324354,9876);
insert into t_test_filter values(4546,778,"test qq nick", 1234567,"title name",2324354,9876);
通过sphinxSE测试查询
select * from t_test_filter_sphinxSE where query="nick;select=IF( FUserId=34,1,0) + IF(Fshopid=1234567,10,0) as match_qq; filter= match_qq, 1,10,11";
select * from t_test_filter_sphinxSE where query="nick;select=IF( FUserId=34,1,0) + IF(Fshopid=1234567,10,0) + IF( FUserId=778,100,0) as match_qq; filter= match_qq, 1,110,111";
这两条语句的作用相同。
2. 上面的语法主要是query里面的语句。
(1) 第一个词是nick,表示需要查询到关键词。
(2)select语句,这个等同于api接口中的SetFilter()。这个是从配置文件的sql_attr_xxxx中,过滤返回的数据。select计算的结果,保存在某个变量名(match_qq)中。这里的计算支持+, -, *, /, <, > <=, >=, =, <>等操作符。
(3)filter语句,这个等同于api接口中的SetFilter()。根据select的结果,用filter过滤。不同的查询条件可以得到不同的组合。这样就可以支持非常复杂的查询过滤条件了。
(2) c-api和php的接口,在coreseek3.2.14应该已经支持,他已经提供了SetSelect()和SetFilter()这两个api,但我没有实试过。
{
type = mysql
sql_user = xxxx
sql_pass = xxx
sql_db = test
sql_port = 3306
sql_attr_bigint = Fshopid
sql_attr_uint = FProperty
sql_attr_uint = FTime
}
{
source = t_test_filter
path = /usr/local/coreseek/var/data/t_test_filter
docinfo = extern
mlock = 0
morphology = none
exceptions = /usr/local/coreseek/var/exceptions.txt
min_word_len = 1
charset_type = zh_cn.gbk
charset_dictpath = /usr/local/coreseek/dict
ngram_len = 1
ngram_chars = U+3000..U+2FA1F
html_strip = 0
blend_mode = trim_none
}
## indexer settings
#############################################################################
{
# memory limit, in bytes, kiloytes (16384K) or megabytes (256M)
# optional, default is 32M, max is 2047M, recommended is 256M to 1024M
mem_limit = 40M
# optional, default is 0 (unlimited)
#
# max_iops = 40
# optional, default is 0 (unlimited)
#
# max_iosize = 1048576
# optional, default is 2M
#
# max_xmlpipe2_field = 4M
# several (currently up to 4) buffers will be allocated
# write buffers are allocated in addition to mem_limit
# optional, default is 1M
#
write_buffer = 1M
}
## searchd settings
#############################################################################
{
# hostname, port, or hostname:port, or /unix/socket/path to listen on
# multi-value, multiple listen points are allowed
# optional, default is 0.0.0.0:9312 (listen on all interfaces, port 9312)
#
# listen = 127.0.0.1
# listen = 192.168.0.1:9312
listen = 9412
# listen = /var/run/searchd.sock
listen = localhost:9406:mysql41
# optional, default is 'searchd.log'
log = /usr/local/coreseek/var/log/searchd_9412.log
# optional, default is empty (do not log queries)
query_log = /usr/local/coreseek/var/log/query_9412.log
# optional, default is 5
read_timeout = 5
# optional, default is 5 minutes
client_timeout = 300
# optional, default is 0 (unlimited)
max_children = 30
# mandatory
pid_file = /usr/local/coreseek/var/log/searchd_9412.pid
# WARNING, THERE'S ALSO PER-QUERY LIMIT, SEE SetLimits() API CALL
# default is 1000 (just like Google)
max_matches = 1000000
# optional, default is 1
seamless_rotate = 1
# optional, default is 0 (do not preopen)
preopen_indexes = 0
# optional, default is 1 (do unlink)
unlink_old = 1
# updates will be automatically dumped to disk this frequently
# optional, default is 0 (disable periodic flush)
#
# attr_flush_period = 900
# optional, default is 0 (precache all dictionaries in RAM)
#
# ondisk_dict_default = 1
# shared between all instances of searchd, disables attr flushes!
# optional, default size is 1M
mva_updates_pool = 1M
# limits both query packets from clients, and responses from agents
# optional, default size is 8M
max_packet_size = 8M
# searchd will (try to) log crashed query to 'crash_log_path.PID' file
# optional, default is empty (do not create crash logs)
#
# crash_log_path = /usr/local/coreseek/var/log/crash
# optional, default is 256
max_filters = 256
# optional, default is 4096
max_filter_values = 4096
# optional, default is 5
#
# listen_backlog = 5
# optional, default is 256K
#
# read_buffer = 256K
# optional, default is 32K
#
# read_unhinted = 32K
}
在sphinx中应用复杂过滤条件的更多相关文章
- 如何在K3 WISE BOS集成开发工具中自定义字段过滤条件
1.结论 对于输入过滤条件后BOS报“列名不正确”的过滤条件,要在列名前增加x2标识 无效的过滤 FNumber ,,,,,) 正确的过滤 x2.FNumber ,,,,,) 2.完全可以不看的探索过 ...
- SQL语句中过滤条件放在on、where、having的区别和联系
摘要:SQL语句中,过滤条件放在不同筛选器on.where和having的区别和联系. 综述 在<SQL语句中过滤条件放在on和where子句中的区别和联系>中,介绍了多表关联SQL语 ...
- SQL优化 查询语句中,用 inner join 作为过滤条件和用where作为过滤条件的区别
前段时间遇到一个存储过程,参数之一是一个字符串,在存储过程中,把字符串拆分成一个临时表之后存为一个key值的临时表,作为其中一个查询条件, 逻辑实现上有两种处理方式 insert into #t se ...
- k3 cloud中提示总账期末结账提示过滤条件太长,请修改此过滤条件
k3 cloud中提示总账期末结账提示过滤条件太长,请修改此过滤条件,如下图所示: 处理方法: 请尝试系统配置文件common.config中将如附件所示的参数值改大,建议值为2000,并在系统清理缓 ...
- SQL语句中过滤条件放在on和where子句中的区别和联系
摘要: 介绍在多表关联SQL语句中,过滤条件放在on和where子句中的区别--inner join中没区别,外连接就不一样. 综述 蚂蚁金服的一道SQL面试题如下:SQL语句中,过滤条件放在on ...
- .NET深入实战系列--EF到底怎么写过滤条件
本文唯一访问地址:http://www.cnblogs.com/yubaolee/p/DynamicLinq.html 对于系统开发来说,按不同字段进行过滤查询是一种常见的需求.在EF中通常的做法是: ...
- 自定义 Azure Table storage 查询过滤条件
本文是在Azure Table storage 基本用法一文的基础上,介绍如何自定义 Azure Table storage 的查询过滤条件.如果您还不太清楚 Azure Table storage ...
- 在DataTable中执行DataTable.Select("条件")返回DataTable;
转:http://blog.csdn.net/hcf_force/article/details/7779062 1.在DataTable中执行DataTable.Select("条件&qu ...
- WireShark系列: 使用WireShark过滤条件抓取特定数据流(zz)
应用抓包过滤,选择Capture | Options,扩展窗口查看到Capture Filter栏.双击选定的接口,如下图所示,弹出Edit Interface Settints窗口. 下图显示了Ed ...
随机推荐
- [Papers]NSE, $u$, Lorentz space [Bjorland-Vasseur, JMFM, 2011]
$$\bex \int_0^T\frac{\sen{\bbu}_{L^{q,\infty}}^p}{\ve+\ln \sex{e+\sen{\bbu}_{L^\infty}}}\rd s<\in ...
- LINQ to SQL使用教程
前些时间用LINQ to SQL做了一些项目,现在打算总结一下,帮助新手快速入门,并写一些别的教程没提到的东西. 一.LINQ to SQL和别的LINQ to XXX有什么关系?二.延迟执行(Def ...
- nmon基础
nmon是分析 AIX 和 Linux 性能的免费工具 最简单的安装方式(Ubuntu apt源) sudo apt-get install nmon 在terminal下打开nmon 敲CMD,出现 ...
- XposedNoRebootModuleSample 不需要频繁重启调试的Xposed 模块源码例子
XposedNoRebootModuleSample(不需要频繁重启调试的Xposed 模块源码例子) Xposed Module Sample No Need To Reboot When Debu ...
- XHTML学习进度备忘
书签:XHTML 高级教程没有看:另外跳过的内容有待跟进 __________________ 学习资源:W3School. _________________ 跳过的内容: 1.“XHTML 简介” ...
- 安装VMware-tools的问题
今天晚上解决了之前在跟着 Linux学习之CentOS(六)--CentOS下VMware-Tools安装 解压部分,cp 压缩文件时,没有通过命令,直接鼠标操作复制到/home/ranjiewen下 ...
- 数据结构(11) -- 邻接表存储图的DFS和BFS
/////////////////////////////////////////////////////////////// //图的邻接表表示法以及DFS和BFS //////////////// ...
- [转]Centos配置国内yum源
原文地址:http://blog.chinaunix.net/uid-23683795-id-3477603.html 网易(163)yum源是国内最好的yum源之一 ,无论是速度还是软件版本,都非常 ...
- Azure Cloud中的Log4Net设置
这里的Cloud包含Worker Role和Web Role,Role是运行在云主机中的,这里的主机和VM有所不同,Windows Azure Role Architecture.我们并没有和本地服务 ...
- MapReduce运行时出现java.lang.NoClassDefFoundError
最近在编写MapReduce程序时遇到了一个错误,错误提示信息为: Error: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.H ...