本文整理匯總了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);
}
示例2: getCustomScoreProvider
import org.apache.lucene.search.function.CustomScoreProvider; //導入依賴的package包/類
@Override
protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) {
return new ScoreFunctionProvider(reader);
}
示例3: getCustomScoreProvider
import org.apache.lucene.search.function.CustomScoreProvider; //導入依賴的package包/類
public CustomScoreProvider getCustomScoreProvider(IndexReader r) throws IOException {
return new RecencyBooster(r);
}