possible to ignore lucene document boost?

时间秒杀一切 提交于 2019-12-13 06:28:03

问题


I am looking for a way to tell the lucene searcher to ignore document boosting on certain queries?

In our search results we usually work with a dominant boost-factor calculated by the age of a document while indexing (the index is rebuild nightly).

Now, I am looking for a way offer search-functionality which ignores the age, but found yet no way to override/ignore the document boost.

Best regards,

Alex


回答1:


Instead of storing your calculated-score as boost, you can store it in a new field, and by implementing CustomScoreQuery + CustomScoreProvider you can control which value(default score or your calculated-one in the field) to return




回答2:


Are you looking for something the QueryParser would understand? Because that is simply not possible.

You're adding the boost somewhere in your code, it is not done by Lucene by default. You'll have to remove this additional piece of code, or make it optional in order to ignore the boost.




回答3:


http://lucene.apache.org/java/3_0_0/api/core/org/apache/lucene/search/Similarity.html

From the point 6, I reckon it is impossible to ignore boosts at search time:

norm(t,d) encapsulates a few (indexing time) boost and length factors:

  • Document boost - set by calling doc.setBoost() before adding the document to the index.
  • Field boost - set by calling field.setBoost() before adding the field to a document.
  • lengthNorm(field) - computed when the document is added to the index in accordance with the number of tokens of this field in the document, so that shorter fields contribute more to the score. LengthNorm is computed by the Similarity class in effect at indexing.

When a document is added to the index, all the above factors are multiplied. If the document has multiple fields with the same name, all their boosts are multiplied together:

(...)

Last, note that search time is too late to modify this norm part of scoring, e.g. by using a different Similarity for search.



来源:https://stackoverflow.com/questions/7526720/possible-to-ignore-lucene-document-boost

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