Word | Number of | Postings list | Total Term Occurrences | Position list |
| Documents | Size(KB) | | Size (GB) |
the | 800,000 | 800 | 4,351 | 4.35 |
of | 892,000 | 892 | 2,795 | 2.8 |
and | 769,000 | 769 | 1,870 | 1.87 |
literature | 453,000 | 453 | 9 | 0.13 |
generation | 414,000 | 414 | 5 | 0.01 |
lives | 432,000 | 432 | 5 | 0.01 |
beat | 278,000 | 278 | 1 | 0.01 |
Total | | 4,037 | | 9 |
To process "the lives and literature of the beat generation" as a Boolean query about 4
大致意思就是对于phrase查询,与布尔查询不同,需要考虑term出现的先后位置,因此要记录其在doc中出现的位置。 越是经常出现的词,倒排表记录着它出现在哪些doc中,并且记录着这些term在doc中出现的位置position信息。因此根据上面的表:
包含the的doc数量为800,000个,而the在所有这些doc中出现了总共 4351 million次,假设倒排表中记录position的单位为一个byte(不考虑增量索引或者其他高端方法的情况下已经是最理想的单位),则记录这些position信息就已经需要4135,000,000个byte,即4.135GB的数据了,意思是即使我们只考虑查询the的情况,硬盘去读取这4GB的数据已经很吃力了。
考虑到我们的实际索引:
由于我们查询的field包括:var_poi_chinese,var_poi_alias,text(text = var_address_chinese+var_poi_chinese),var_address_chinese,BigTag。而这些信息里面包含 “市” 的field至少有address,而像poi以及text也是有极大的可能包含 “市” 信息的。
所以假设我们有10 million个doc,那么当我们查询 “上海市复旦大学”的时候,光是切分出的 “市”这个term它的position信息就至少有 10,000,000个之多,而实际情况至少会将这个数翻一倍,这还是不考虑 “市”这个此项在倒排表中所包含的其他信息。于是我们对于“市”这个无关紧要的term就进行了很多不必要的操作,而且就因为这个 所有doc中都有的“市”,我们最终查询到的结果就包含了索引中的所有doc。而且这里只是考虑到了取出“市”这个term对应的position信息而已,忽视了很多其他开销的情况下。
因此,根据这个时机情况,我们就需要考虑
于是query:“上海市” 进行分词和过滤以后得到的term如下(这里用的分词器是NGram min=1 max=3):
上,海,海_市,市_上海,上海,海市,上海市
这种处理方法增加了索引的大小,但是在查询时能够有效的减少common words对于查询带来的损害。
加入到stopwords中的common words:省,市,县,地区,自治州,郊县,城区