2011-03-07 14 views
0

问题我应该如何在MyISAM搜索索引中处理重复条目的权重?

我使用的是myisam_ftdump的结果生成一个搜索建议表。这个过程进行得很顺利,但是索引中多次出现很多单词。显然,我可以只是SELECT distinct term FROM suggestions ORDER BY weight,但这不会惩罚不止一次出现的单词吗?

如果是这样,是否有合并行的简明公式?

如果不是,我应该保留哪些行(例如,最高权重,最低权重)?

示例数据

+-----+------------+----------+ 
| id | word  | weight | 
+-----+------------+----------+ 
| 670 | young  | 0.416022 | 
| 669 | york  | 0.54944 | 
| 668 | years  | 0.281683 | 
| 667 | years  | 0.416022 | 
| 666 | wrote  | 0.416022 | 
| 665 | written | 0.35841 | 
| 664 | writing | 0.29518 | 
| 663 | wright  | 0.281683 | 
| 662 | witness | 0.281683 | 
| 661 | wiesenthal | 0.452452 | 
| 660 | white  | 0.35841 | 
| 659 | white  | 0.281683 | 
| 658 | wgbh  | 0.369332 | 
| 657 | weighs  | 0.35841 | 
+-----+------------+----------+ 

尤其见 '白色' 和 '年'。

回答

1

它看起来像你跑myisam_ftdump -d。我想你想用myisam_ftdump -c代替。

这会给你每个单词一行,以及该单词出现在索引中的次数及其全局权重。

这里有-c与-d商务部:

-c, --count   Calculate per-word stats (counts and global weights). 
    -d, --dump   Dump index (incl. data offsets and word weights). 
+0

感谢,就像我在我的咖啡需要更多的咖啡因,我掩盖权在'-c'选项。 – fncomp