博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sphinx 增量索引与主索引使用测试
阅读量:5079 次
发布时间:2019-06-12

本文共 3210 字,大约阅读时间需要 10 分钟。

2013年10月28日 15:01:16

首先对新增的商品建立增量索引,搜索时只使用增量索引:

1 array (size=1)2   0 => 3     array (size=6)4       'gid' => string '300233' (length=6)5       'weight' => string '1500' (length=4)6       'comweight' => float 17       'ge' => string '70' (length=2)8       'ce' => string '34' (length=2)9       'mysum' => string '104' (length=3)
View Code

新商品的id:300233 权重: 1500

然后重建主索引,搜索时只使用主索引:

1 2 =>  2     array (size=6) 3       'gid' => string '300231' (length=6) 4       'weight' => string '1690' (length=4) 5       'comweight' => float 1 6       'ge' => string '70' (length=2) 7       'ce' => string '34' (length=2) 8       'mysum' => string '104' (length=3) 9   3 => 10     array (size=6)11       'gid' => string '300232' (length=6)12       'weight' => string '1690' (length=4)13       'comweight' => float 114       'ge' => string '70' (length=2)15       'ce' => string '34' (length=2)16       'mysum' => string '104' (length=3)17   4 => 18     array (size=6)19       'gid' => string '300233' (length=6)20       'weight' => string '1690' (length=4)21       'comweight' => float 122       'ge' => string '70' (length=2)23       'ce' => string '34' (length=2)24       'mysum' => string '104' (length=3)
View Code

此时,那个新商品(id:300233)的权重变为 1690

再然后搜索时同时使用增量索引和主索引

1 $sphObj->query($keyword, 'goods,goods_zl'); 2  3 2 =>  4     array (size=6) 5       'gid' => string '300231' (length=6) 6       'weight' => string '1690' (length=4) 7       'comweight' => float 1 8       'ge' => string '70' (length=2) 9       'ce' => string '34' (length=2)10       'mysum' => string '104' (length=3)11   3 => 12     array (size=6)13       'gid' => string '300232' (length=6)14       'weight' => string '1690' (length=4)15       'comweight' => float 116       'ge' => string '70' (length=2)17       'ce' => string '34' (length=2)18       'mysum' => string '104' (length=3)19   4 => 20     array (size=6)21       'gid' => string '300233' (length=6)22       'weight' => string '1500' (length=4)23       'comweight' => float 124       'ge' => string '70' (length=2)25       'ce' => string '34' (length=2)26       'mysum' => string '104' (length=3)
View Code

此时的结果说明:增量索引中该新商品覆盖掉了主索引中的那个商品, but why!?

然后一个有意思的测试,在查询时调换下两个索引的前后顺序(第一行代码),结果:

1 $sphObj->query($keyword, 'goods_zl,goods'); 2  3 2 =>  4     array (size=6) 5       'gid' => string '300231' (length=6) 6       'weight' => string '1690' (length=4) 7       'comweight' => float 1 8       'ge' => string '70' (length=2) 9       'ce' => string '34' (length=2)10       'mysum' => string '104' (length=3)11   3 => 12     array (size=6)13       'gid' => string '300232' (length=6)14       'weight' => string '1690' (length=4)15       'comweight' => float 116       'ge' => string '70' (length=2)17       'ce' => string '34' (length=2)18       'mysum' => string '104' (length=3)19   4 => 20     array (size=6)21       'gid' => string '300233' (length=6)22       'weight' => string '1690' (length=4)23       'comweight' => float 124       'ge' => string '70' (length=2)25       'ce' => string '34' (length=2)26       'mysum' => string '104' (length=3)
View Code

结论,相同的商品在主索引和增量索引中只保留一个,根据查询语句中的顺序后者索引会覆盖掉前边索引里相同的商品(或文档)

还有诡异的事情,未完待续... ...

转载于:https://www.cnblogs.com/iLoveMyD/p/3392518.html

你可能感兴趣的文章
入门系列2
查看>>
胶体电荷重整化
查看>>
LeetCode -- House Robber II
查看>>
转 Docker 从零开始制作基础镜像[centos]
查看>>
python学习之Numpy.genfromtxt
查看>>
分割DataTable
查看>>
ajax简介及JS写原生ajax
查看>>
排序 一
查看>>
AppWidgetProvider 应用
查看>>
DT大数据梦工厂 第57讲
查看>>
狗日的京东云擎收费了。原来写的东西都没了。
查看>>
unity 看到Sphere内部,通过Sphere播放全景视频时候遇到的问题
查看>>
认识HTML
查看>>
maven项目上有红色的感叹号
查看>>
CF724B. Batch Sort[枚举]
查看>>
HDU 1724 Ellipse [辛普森积分]
查看>>
CF 716E. Digit Tree [点分治]
查看>>
HDU2089 不要62 BZOJ1026: [SCOI2009]windy数 [数位DP]
查看>>
PHP利用P3P实现跨域
查看>>
Mybatis--映射器注解
查看>>