Lucene基础

LuceneBoost详解

If you wish to boost the title field for every query then it would be
easiest to boost the title clause of your query, with Query.setBoost().
Field.setBoost() should only be used when you want to give a field
different boosts in different documents, but since you want to boost all
titles by the same amount, you'll find it easier to boost at query time.
That way you can experiment with the boost amount without re-building
the index.  The values of Field.setBoost() are built into the index and
are harder to change.  Thus I recommend using Query.setBoost() instead.
Construct a query for each field to be searched (by hand, or with the
QueryParser), boost each of these field queries separately, then build a
BooleanQuery that combines these into a single Query that you then
execute.  I hope that makes sense.

Field.setBoost(float num) 是在创建Index时创建的,并且会被写入到索引文件中。会对当前Field产生影响。

而在Document.setBoost()会对当前的文档相对于别的文档来说产生影响。这个值在创建完Document的Index时,不会被存储起来,设置的值实际上会添加到该Document的Field上,并将Boost与Field自身设置的Boost进行相加处理。

query.setBoost()是在查询时动态的设置Boost,不会对创建出来的index产生影响。

建议的做法: 为每一个要搜索的Field创建一个Query对象,分别为创建出来的query设置BOost值,然后再创建一个BooleanQuery对象(该对象将上述创建出来的Query对象合并到一起。)

 

对一个索引文件夹同时只能有一个IndexWriter对象,即只能存在一个锁文件(write.lock)。所以说对同一个索引文件夹设置一个IndexWriter缓冲池是不可取的

转载于:https://my.oschina.net/hotbain/blog/73632

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值