Boost fresh documents with Lucene(使用 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 提升新文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Lucene 提升新文档
基础教程推荐
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- Struts2 URL 无法访问 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
