scoringScorers.add(scorer); return new ConjunctionScorer(weight, requiredScorers, scoringScorers);
new ConjunctionScorer(getSimilarity(searcher)); for (int i = 0 ; i < weights.size(); i++) { Weight w = (Weight)weights.elementAt(i); if (subScorer == null) return null; result.add(subScorer);
public boolean skipTo(int target) throws IOException { Iterator i = scorers.iterator(); while (more && i.hasNext()) { more = ((Scorer)i.next()).skipTo(target); } if (more) sortScorers(); // re-sort scorers return doNext(); }
private void init() throws IOException { more = scorers.size() > 0; // compute coord factor coord = getSimilarity().coord(scorers.size(), scorers.size()); // move each scorer to its first entry Iterator i = scorers.iterator(); while (more && i.hasNext()) { more = ((Scorer)i.next()).next(); } if (more) sortScorers(); // initial sort of list firstTime = false; }
public ConjunctionScorer(Similarity similarity, Scorer[] scorers) throws IOException { super(similarity); this.scorers = scorers; coord = getSimilarity().coord(this.scorers.length, this.scorers.length); }
public ConjunctionScorer(Similarity similarity, Scorer[] scorers) throws IOException { super(similarity); this.scorers = scorers; coord = getSimilarity().coord(this.scorers.length, this.scorers.length); }
@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)); } }