使用 Lucene 提升新文档 [英] Boost fresh documents with Lucene

查看:22
本文介绍了使用 Lucene 提升新文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Lucene 是否提供了一种增加新文档的方法?

Does Lucene provide a means to boost fresh documents?

例如,假设 Lucene 文档包含一个日期字段.是否有可能在不让用户改变她的查询的情况下,以更高的分数呈现最新的文档?

For example suppose that the Lucene document includes a date field. Is it possible, without having the user to alter her query anyhow, to present the most recent documents with a higher score?

我不想采用粗略的按日期排序"解决方案,因为它会完全取消评分算法.

I do not want to resort to a coarse "sort by date" solution as it will completely cancel the scoring algorithm.

推荐答案

将文档放入索引时使用 Document.setBoost(float value).

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.

例如,从第 1 天文档的提升值 0 开始.每天,boost 递增 1.它是一个浮点值,每年递增 365 会持续很长时间.

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.

这篇关于使用 Lucene 提升新文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆