lucene學習之自定義評分

2021-07-11 08:21:52 字數 742 閱讀 5134

想要根據城市來自定義評分,原來的輸出:

根據【你好.我是jack】 一共找到3檔案

編號:0 分數: 1.0 id: 1 city: 北京

編號:1 分數: 1.0 id: 2 city: 南京

編號:2 分數: 1.0 id: 3 city: 上海

自己新建的query物件:

public class myfieldscorequery extends customscorequery

@override

protected customscoreprovider getcustomscoreprovider(leafreadercontext context)

}覆蓋customscoreprovider:

public class mycustomscoreprovider extends customscoreprovider

@override

public  float customscore(int doc, float subqueryscore, float valsrcscore) throws ioexception

return score;}}

然後輸出如下:

根據【你好.我是jack】 一共找到3檔案

編號:2 分數: 100.0 id: 3 city: 上海

編號:0 分數: 1.0 id: 1 city: 北京

編號:1 分數: 1.0 id: 2 city: 南京

18 學習Lucene3 5索引之自定義評分

自定義評分流程 1.建立乙個評分域 2.根據原有query termquery 和評分域query scorequery 建立自定義的mycustomscorequery物件 2.1建立自定義的mycustomscorequery物件 2.2過載 getcustomscoreprovider 方法 ...

solr 相關度評分,自定義評分

ps 臨時寫的,大體的實現和簡單版,以後會不斷完善 部落格和 solr是基於lucene的全文檢索 搜尋引擎,和一般查資料庫相比,solr的乙個特色就是它的相關度評分。這裡介紹一下它的自定義 相關度評分。在實際的業務中,可能不需要這麼複雜的相關度,是需要簡單粗暴的 按照我指定的規則計算相關度,並按照...

solr自定義評分器

solr服務搭建完成 索引已建立,可以進行搜尋 現象 搜尋 美女 後,美女美女美女美女 文件會出現第一位。但實際系統中可能並不需要 這種結果 這個時候的解決辦法 根據自己業務需要進行重寫評分器 1.自定義評分器 package cn.xxt.solr.util import org.apache.l...