在创建索引时设置boost值:可以针对Field设置boost,也可以针对Document设置boost值。针对Field设置boost必须搜索时匹配到该Field在计算相关度得分时才有效,针对Document设置Field则在搜索时只要匹配到该Document的任意Field在计算相关度得分都有效。
<add>
<doc>
<field name="id">a01</field>
<field name="product_name" boost="20.0">幸福一家人</field>
<field name="product_description" >我们是幸福一家人</field>
</doc>
<doc boost="30.0">
<field name="id">a02</field>
<field name="product_name">幸福两家人</field>
<field name="product_description" >我们是幸福两家人</field>
</doc>
</add>
<commit/>
在创建搜索时设置域的boost值:搜索匹配到的域如果boost值设置的高则计算的相关度得分就可能会高。
<add>
<doc>
<field name="id">a03</field>
<field name="product_name">lucene实战</field>
<field name="product_description" >这是一本讲解全文检索技术的书籍</field>
</doc>
<doc>
<field name="id">a04</field>
<field name="product_name">全文检索</field>
<field name="product_description" >Lucene是一个全文检索工具包</field>
</doc>
</add>
<commit/>
原文:http://www.cnblogs.com/wesly186/p/b2a0d81d679c3b73d26fe96a42fe45d1.html