如何在索引期间为每个文档中的每个术语定义一个提升因子?

Fel*_*mel 2 lucene scoring

我想在Lucene的相似性方程中插入另一个得分因子.问题是我不能只是覆盖Similarity类,因为它不知道它是计算分数的文档和术语.

例如,在包含以下文本的文档中:

The cat is in the top of the tree, and he is going to stay there.
Run Code Online (Sandbox Code Playgroud)

我有一个自己的算法,为每个人分配本文档中的术语,分别表示每个术语对整个文档的重要程度.每个单词的可能得分是:

cat: 0.789212
tree: 0.633423
top: 0.412315
stay: 0.123912
there: 0.0999842
going: 0.00988412
...
Run Code Online (Sandbox Code Playgroud)

每个单词的得分因文档而异.例如,在另一个文档中cat可能有得分:0.0023912

我想把这个分数加到Lucene的得分上,但我对如何做到这一点感到很失望.

有小费吗?

baj*_*ife 5

使用Lucene的Payload功能:

来自:http://www.lucidimagination.com/blog/2009/08/05/getting-started-with-payloads/

  1. 在索引期间向一个或多个令牌添加有效负载.
  2. 重写Similarity类以处理评分有效负载
  3. 在搜索过程中使用有效负载感知查询