scoringScorers.add(scorer); return new ConjunctionScorer(weight, requiredScorers, scoringScorers);
@Override public Scorer get(long leadCost) throws IOException { // three cases: conjunction, disjunction, or mix leadCost = Math.min(leadCost, cost()); // pure conjunction if (subs.get(Occur.SHOULD).isEmpty()) { return excl(req(subs.get(Occur.FILTER), subs.get(Occur.MUST), leadCost), subs.get(Occur.MUST_NOT), leadCost); } // pure disjunction if (subs.get(Occur.FILTER).isEmpty() && subs.get(Occur.MUST).isEmpty()) { return excl(opt(subs.get(Occur.SHOULD), minShouldMatch, needsScores, leadCost), subs.get(Occur.MUST_NOT), leadCost); } // conjunction-disjunction mix: // we create the required and optional pieces, and then // combine the two: if minNrShouldMatch > 0, then it's a conjunction: because the // optional side must match. otherwise it's required + optional if (minShouldMatch > 0) { Scorer req = excl(req(subs.get(Occur.FILTER), subs.get(Occur.MUST), leadCost), subs.get(Occur.MUST_NOT), leadCost); Scorer opt = opt(subs.get(Occur.SHOULD), minShouldMatch, needsScores, leadCost); return new ConjunctionScorer(weight, Arrays.asList(req, opt), Arrays.asList(req, opt)); } else { assert needsScores; return new ReqOptSumScorer( excl(req(subs.get(Occur.FILTER), subs.get(Occur.MUST), leadCost), subs.get(Occur.MUST_NOT), leadCost), opt(subs.get(Occur.SHOULD), minShouldMatch, needsScores, leadCost)); } }
private Scorer dualConjunctionSumScorer(Scorer req1, Scorer req2) throws IOException { // non counting. return new ConjunctionScorer(defaultSimilarity, new Scorer[]{req1, req2}); // All scorers match, so defaultSimilarity always has 1 as // the coordination factor. // Therefore the sum of the scores of two scorers // is used as score. }
private Scorer dualConjunctionSumScorer(Scorer req1, Scorer req2) throws IOException { // non counting. return new ConjunctionScorer(defaultSimilarity, new Scorer[]{req1, req2}); // All scorers match, so defaultSimilarity always has 1 as // the coordination factor. // Therefore the sum of the scores of two scorers // is used as score. }
private Scorer countingConjunctionSumScorer(List requiredScorers) throws IOException { // each scorer from the list counted as a single matcher final int requiredNrMatchers = requiredScorers.size(); return new ConjunctionScorer(defaultSimilarity, requiredScorers) { private int lastScoredDoc = -1; public float score() throws IOException { if (this.doc() >= lastScoredDoc) { lastScoredDoc = this.doc(); coordinator.nrMatchers += requiredNrMatchers; } // All scorers match, so defaultSimilarity super.score() always has 1 as // the coordination factor. // Therefore the sum of the scores of the requiredScorers // is used as score. return super.score(); } }; }
private Scorer countingConjunctionSumScorer(List requiredScorers) throws IOException { // each scorer from the list counted as a single matcher final int requiredNrMatchers = requiredScorers.size(); return new ConjunctionScorer(defaultSimilarity, requiredScorers) { private int lastScoredDoc = -1; public float score() throws IOException { if (this.doc() >= lastScoredDoc) { lastScoredDoc = this.doc(); coordinator.nrMatchers += requiredNrMatchers; } // All scorers match, so defaultSimilarity super.score() always has 1 as // the coordination factor. // Therefore the sum of the scores of the requiredScorers // is used as score. return super.score(); } }; }
scoringScorers.add(scorer); return new ConjunctionScorer(weight, requiredScorers, scoringScorers);
@Override public Scorer get(long leadCost) throws IOException { // three cases: conjunction, disjunction, or mix leadCost = Math.min(leadCost, cost()); // pure conjunction if (subs.get(Occur.SHOULD).isEmpty()) { return excl(req(subs.get(Occur.FILTER), subs.get(Occur.MUST), leadCost), subs.get(Occur.MUST_NOT), leadCost); } // pure disjunction if (subs.get(Occur.FILTER).isEmpty() && subs.get(Occur.MUST).isEmpty()) { return excl(opt(subs.get(Occur.SHOULD), minShouldMatch, needsScores, leadCost), subs.get(Occur.MUST_NOT), leadCost); } // conjunction-disjunction mix: // we create the required and optional pieces, and then // combine the two: if minNrShouldMatch > 0, then it's a conjunction: because the // optional side must match. otherwise it's required + optional if (minShouldMatch > 0) { Scorer req = excl(req(subs.get(Occur.FILTER), subs.get(Occur.MUST), leadCost), subs.get(Occur.MUST_NOT), leadCost); Scorer opt = opt(subs.get(Occur.SHOULD), minShouldMatch, needsScores, leadCost); return new ConjunctionScorer(weight, Arrays.asList(req, opt), Arrays.asList(req, opt)); } else { assert needsScores; return new ReqOptSumScorer( excl(req(subs.get(Occur.FILTER), subs.get(Occur.MUST), leadCost), subs.get(Occur.MUST_NOT), leadCost), opt(subs.get(Occur.SHOULD), minShouldMatch, needsScores, leadCost)); } }
return new ConjunctionScorer(this, required, requiredScoring, disableCoord ? 1.0F : coord(requiredScoring.size(), maxCoord));
return new ConjunctionScorer(this, required, requiredScoring, disableCoord ? 1.0F : coord(requiredScoring.size(), maxCoord));
new ConjunctionScorer(getSimilarity(searcher)); for (int i = 0 ; i < weights.size(); i++) { Weight w = (Weight)weights.elementAt(i);
return new ConjunctionScorer(this, Arrays.asList(req, opt), Arrays.asList(req, opt), 1F); } else { return new ReqOptSumScorer(req, opt); return new ConjunctionScorer(this, Arrays.asList(req, opt), Arrays.asList(req, opt), coord(requiredScoring.size()+1, maxCoord)); } else { float coordReq = coord(requiredScoring.size(), maxCoord);
return new ConjunctionScorer(this, Arrays.asList(req, opt), Arrays.asList(req, opt), 1F); } else { return new ReqOptSumScorer(req, opt); return new ConjunctionScorer(this, Arrays.asList(req, opt), Arrays.asList(req, opt), coord(requiredScoring.size()+1, maxCoord)); } else { float coordReq = coord(requiredScoring.size(), maxCoord);