當前位置: 首頁>>代碼示例>>Java>>正文


Java CustomScoreProvider類代碼示例

本文整理匯總了Java中org.apache.lucene.search.function.CustomScoreProvider的典型用法代碼示例。如果您正苦於以下問題:Java CustomScoreProvider類的具體用法?Java CustomScoreProvider怎麽用?Java CustomScoreProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CustomScoreProvider類屬於org.apache.lucene.search.function包,在下文中一共展示了CustomScoreProvider類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCustomScoreQuery

import org.apache.lucene.search.function.CustomScoreProvider; //導入依賴的package包/類
public void testCustomScoreQuery() throws Throwable {
  Query q = new QueryParser(Version.LUCENE_41,
                            "content",
                            new StandardAnalyzer(
                              Version.LUCENE_41))
               .parse("the green hat");
  FieldScoreQuery qf = new FieldScoreQuery("score",
                                           FieldScoreQuery.Type.BYTE);
  CustomScoreQuery customQ = new CustomScoreQuery(q, qf) {
    public CustomScoreProvider getCustomScoreProvider(IndexReader r) {
      return new CustomScoreProvider(r) {
        public float customScore(int doc,
                                 float subQueryScore,
                                 float valSrcScore) {
          return (float) (Math.sqrt(subQueryScore) * valSrcScore);
        }
      };
    }
  };

  TopDocs hits = s.search(customQ, 10);
  assertEquals(2, hits.scoreDocs.length);
  
  assertEquals(1, hits.scoreDocs[0].doc);           //
  assertEquals(0, hits.scoreDocs[1].doc);
}
 
開發者ID:xuzhikethinker,項目名稱:t4f-data,代碼行數:27,代碼來源:FunctionQueryTest.java

示例2: getCustomScoreProvider

import org.apache.lucene.search.function.CustomScoreProvider; //導入依賴的package包/類
@Override
protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) {
	return new ScoreFunctionProvider(reader);
}
 
開發者ID:jaeksoft,項目名稱:opensearchserver,代碼行數:5,代碼來源:ScoreFunctionQuery.java

示例3: getCustomScoreProvider

import org.apache.lucene.search.function.CustomScoreProvider; //導入依賴的package包/類
public CustomScoreProvider getCustomScoreProvider(IndexReader r) throws IOException {
  return new RecencyBooster(r);
}
 
開發者ID:xuzhikethinker,項目名稱:t4f-data,代碼行數:4,代碼來源:FunctionQueryTest.java


注:本文中的org.apache.lucene.search.function.CustomScoreProvider類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。