What is better ? One big field or many small?

我怕爱的太早我们不能终老 提交于 2020-01-04 11:00:06

问题


I'm about writing a search engine based on Zend Search Lucène.

My objects have many different fields (10 text type), and i would like to know which of these ways is the best. (All fields are unstored, just indexed, I don't need to recover them.)

One big field, (concatenation of many small fields) :

$content = $textfield1 . $textfield2 . $textfield3 . $textfield4 ...
Zend_Search_Lucene_Field::unStored("content", $content);

OR

Many small fields :

Zend_Search_Lucene_Field::unStored("content", $textfield1);
Zend_Search_Lucene_Field::unStored("content2", $textfield2);
Zend_Search_Lucene_Field::unStored("content3", $textfield3);
....
....

Each fields may contain lot of text (about 500 words and more).


回答1:


If the content of these fields is similar, then performance-wise, it's better to have one field than several ones (assuming that most of the time you want to search across all of them).

Lucene stores terms for fields in one big dictionary as concatenation of form {field}{term}, so if you don't need to treat the fields separately it's better to throw them into one bag. This way, you will have way smaller dictionary (especially, if the terms for these fields are similar) and less disk seeks during the search (the sum of postings list scanned will remain roughly the same).



来源:https://stackoverflow.com/questions/9213092/what-is-better-one-big-field-or-many-small

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!