sphinx 增量索引与主索引使用测试

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 1

7       '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 1

14       '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 1

22       '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 1

16       '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 1

24       '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 1

16       '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 1

24       'ge' => string '70' (length=2)

25       'ce' => string '34' (length=2)

26       'mysum' => string '104' (length=3)
View Code

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

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

你可能感兴趣的:(sphinx)