Boost fresh documents with Lucene

吃可爱长大的小学妹 提交于 2019-11-30 21:11:42

Use Document.setBoost(float value) when putting documents into the index.

You can either constantly re-adjust the value on existing documents, OR have a float value that increments with date, so that you only need to apply it to the time that documents are inserted.

For example, start with a boost value of 0 for day 1 documents. Each day, increment the boost by 1. It's a float value, incrementing by 365 each year will last a long time.

You may have to experiment with the strength of the boost to get the effect you want.

You can see Lucene in Action. In the second edition, pg. 187 they give a way to do it. Basically, you will want to write your own query which extends CustomScoreQuery, and adds a boost.

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