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


Java Explanation.isMatch方法代碼示例

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


在下文中一共展示了Explanation.isMatch方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
    Explanation subQueryExpl = subQueryWeight.explain(context, doc);
    if (!subQueryExpl.isMatch()) {
        return subQueryExpl;
    }
    Explanation expl;
    if (function != null) {
        Explanation functionExplanation = function.getLeafScoreFunction(context).explainScore(doc, subQueryExpl);
        expl = combineFunction.explain(subQueryExpl, functionExplanation, maxBoost);
    } else {
        expl = subQueryExpl;
    }
    if (minScore != null && minScore > expl.getValue()) {
        expl = Explanation.noMatch("Score value is too low, expected at least " + minScore + " but got " + expl.getValue(), expl);
    }
    return expl;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:19,代碼來源:FunctionScoreQuery.java

示例2: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
public Explanation explain(int topLevelDocId, SearchContext context, RescoreSearchContext rescoreContext,
                           Explanation sourceExplanation) throws IOException {
    QueryRescoreContext rescore = (QueryRescoreContext) rescoreContext;
    ContextIndexSearcher searcher = context.searcher();
    if (sourceExplanation == null) {
        // this should not happen but just in case
        return Explanation.noMatch("nothing matched");
    }
    // TODO: this isn't right?  I.e., we are incorrectly pretending all first pass hits were rescored?  If the requested docID was
    // beyond the top rescoreContext.window() in the first pass hits, we don't rescore it now?
    Explanation rescoreExplain = searcher.explain(rescore.query(), topLevelDocId);
    float primaryWeight = rescore.queryWeight();

    Explanation prim;
    if (sourceExplanation.isMatch()) {
        prim = Explanation.match(
                sourceExplanation.getValue() * primaryWeight,
                "product of:", sourceExplanation, Explanation.match(primaryWeight, "primaryWeight"));
    } else {
        prim = Explanation.noMatch("First pass did not match", sourceExplanation);
    }

    // NOTE: we don't use Lucene's Rescorer.explain because we want to insert our own description with which ScoreMode was used.  Maybe
    // we should add QueryRescorer.explainCombine to Lucene?
    if (rescoreExplain != null && rescoreExplain.isMatch()) {
        float secondaryWeight = rescore.rescoreQueryWeight();
        Explanation sec = Explanation.match(
                rescoreExplain.getValue() * secondaryWeight,
                "product of:",
                rescoreExplain, Explanation.match(secondaryWeight, "secondaryWeight"));
        QueryRescoreMode scoreMode = rescore.scoreMode();
        return Explanation.match(
                scoreMode.combine(prim.getValue(), sec.getValue()),
                scoreMode + " of:",
                prim, sec);
    } else {
        return prim;
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:41,代碼來源:QueryRescorer.java

示例3: writeExplanation

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
public static void writeExplanation(StreamOutput out, Explanation explanation) throws IOException {
    out.writeBoolean(explanation.isMatch());
    out.writeString(explanation.getDescription());
    Explanation[] subExplanations = explanation.getDetails();
    out.writeVInt(subExplanations.length);
    for (Explanation subExp : subExplanations) {
        writeExplanation(out, subExp);
    }
    if (explanation.isMatch()) {
        out.writeFloat(explanation.getValue());
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,代碼來源:Lucene.java

示例4: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
public Explanation explain(int topLevelDocId, SearchContext context, RescoreSearchContext rescoreContext,
                           Explanation sourceExplanation) throws IOException {
    QueryRescoreContext rescore = (QueryRescoreContext) rescoreContext;
    ContextIndexSearcher searcher = context.searcher();
    if (sourceExplanation == null) {
        // this should not happen but just in case
        return Explanation.noMatch("nothing matched");
    }
    // TODO: this isn't right?  I.e., we are incorrectly pretending all first pass hits were rescored?  If the requested docID was
    // beyond the top rescoreContext.window() in the first pass hits, we don't rescore it now?
    Explanation rescoreExplain = searcher.explain(rescore.query(), topLevelDocId);
    float primaryWeight = rescore.queryWeight();

    Explanation prim;
    if (sourceExplanation.isMatch()) {
        prim = Explanation.match(
                sourceExplanation.getValue() * primaryWeight,
                "product of:", sourceExplanation, Explanation.match(primaryWeight, "primaryWeight"));
    } else {
        prim = Explanation.noMatch("First pass did not match", sourceExplanation);
    }

    // NOTE: we don't use Lucene's Rescorer.explain because we want to insert our own description with which ScoreMode was used.  Maybe
    // we should add QueryRescorer.explainCombine to Lucene?
    if (rescoreExplain != null && rescoreExplain.isMatch()) {
        float secondaryWeight = rescore.rescoreQueryWeight();
        Explanation sec = Explanation.match(
                rescoreExplain.getValue() * secondaryWeight,
                "product of:",
                rescoreExplain, Explanation.match(secondaryWeight, "secondaryWeight"));
        ScoreMode scoreMode = rescore.scoreMode();
        return Explanation.match(
                scoreMode.combine(prim.getValue(), sec.getValue()),
                scoreMode + " of:",
                prim, sec);
    } else {
        return prim;
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:41,代碼來源:QueryRescorer.java


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