@Override public Spans getSpans(final LeafReaderContext context, Postings requiredPostings) throws IOException { Spans matchSpans = matchWeight.getSpans(context, requiredPostings); return (matchSpans == null) ? null : new FilterSpans(matchSpans) { @Override protected AcceptStatus accept(Spans candidate) throws IOException { return acceptPosition(candidate); } }; }
@Override public void extractTermContexts(Map<Term, TermContext> contexts) { for (SpanWeight w : subWeights) { w.extractTermContexts(contexts); } }
@Override public void extractTerms(Set<Term> terms) { for (SpanWeight w : subWeights) { w.extractTerms(terms); } }
@Override public SpanScorer scorer(LeafReaderContext context) throws IOException { final Spans spans = getSpans(context, Postings.POSITIONS); if (spans == null) { return null; } final Similarity.SimScorer docScorer = getSimScorer(context); return new SpanScorer(this, spans, docScorer); }
@Override public Explanation explain(LeafReaderContext context, int doc) throws IOException { SpanScorer scorer = scorer(context); if (scorer != null) { int newDoc = scorer.iterator().advance(doc); if (newDoc == doc) { float freq = scorer.sloppyFreq(); SimScorer docScorer = similarity.simScorer(simWeight, context); Explanation freqExplanation = Explanation.match(freq, "phraseFreq=" + freq); Explanation scoreExplanation = docScorer.explain(doc, freqExplanation); return Explanation.match(scoreExplanation.getValue(), "weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:", scoreExplanation); } } return Explanation.noMatch("no matching term"); }
@Override public SpanScorer scorer(LeafReaderContext context) throws IOException { return weight.scorer(context); }
@Override public PayloadSpanScorer scorer(LeafReaderContext context) throws IOException { Spans spans = getSpans(context, Postings.PAYLOADS); if (spans == null) return null; SimScorer docScorer = innerWeight.getSimScorer(context); PayloadSpans payloadSpans = new PayloadSpans(spans, docScorer); return new PayloadSpanScorer(this, payloadSpans, docScorer); }
/** * Create a new SpanWeight * @param query the parent query * @param searcher the IndexSearcher to query against * @param termContexts a map of terms to termcontexts for use in building the similarity. May * be null if scores are not required * @throws IOException on error */ public SpanWeight(SpanQuery query, IndexSearcher searcher, Map<Term, TermContext> termContexts, float boost) throws IOException { super(query); this.field = query.getField(); this.similarity = searcher.getSimilarity(termContexts != null); this.simWeight = buildSimWeight(query, searcher, termContexts, boost); }
@Override public Explanation explain(LeafReaderContext context, int doc) throws IOException { return weight.explain(context, doc); }
protected Weight createWeight(Searcher searcher) { return new SpanWeight(this, searcher); }
@Override public Explanation explain(LeafReaderContext context, int doc) throws IOException { SpanScorer scorer = scorer(context); if (scorer != null) { int newDoc = scorer.iterator().advance(doc); if (newDoc == doc) { float freq = scorer.sloppyFreq(); SimScorer docScorer = similarity.simScorer(simWeight, context); Explanation freqExplanation = Explanation.match(freq, "phraseFreq=" + freq); Explanation scoreExplanation = docScorer.explain(doc, freqExplanation); return Explanation.match(scoreExplanation.getValue(), "weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:", scoreExplanation); } } return Explanation.noMatch("no matching term"); }
@Override public SpanScorer scorer(LeafReaderContext context) throws IOException { final Spans spans = getSpans(context, Postings.POSITIONS); if (spans == null) { return null; } final Similarity.SimScorer docScorer = getSimScorer(context); return new SpanScorer(this, spans, docScorer); }
@Override public SpanScorer scorer(LeafReaderContext context) throws IOException { return weight.scorer(context); }
@Override public PayloadSpanScorer scorer(LeafReaderContext context) throws IOException { Spans spans = getSpans(context, Postings.PAYLOADS); if (spans == null) return null; SimScorer docScorer = innerWeight.getSimScorer(context); PayloadSpans payloadSpans = new PayloadSpans(spans, docScorer); return new PayloadSpanScorer(this, payloadSpans, docScorer); }
/** * Create a new SpanWeight * @param query the parent query * @param searcher the IndexSearcher to query against * @param termContexts a map of terms to termcontexts for use in building the similarity. May * be null if scores are not required * @throws IOException on error */ public SpanWeight(SpanQuery query, IndexSearcher searcher, Map<Term, TermContext> termContexts) throws IOException { super(query); this.field = query.getField(); this.similarity = searcher.getSimilarity(termContexts != null); this.simWeight = buildSimWeight(query, searcher, termContexts); }
@Override public Explanation explain(LeafReaderContext context, int doc) throws IOException { return weight.explain(context, doc); }
protected Weight createWeight(Searcher searcher) throws IOException { return new SpanWeight(this, searcher); }
ArrayList<Spans> prepareConjunction(final LeafReaderContext context, Postings postings) throws IOException { Spans bigSpans = bigWeight.getSpans(context, postings); if (bigSpans == null) { return null; } Spans littleSpans = littleWeight.getSpans(context, postings); if (littleSpans == null) { return null; } ArrayList<Spans> bigAndLittle = new ArrayList<>(); bigAndLittle.add(bigSpans); bigAndLittle.add(littleSpans); return bigAndLittle; }
@Override public Explanation explain(LeafReaderContext context, int doc) throws IOException { SpanScorer scorer = scorer(context); if (scorer != null) { int newDoc = scorer.iterator().advance(doc); if (newDoc == doc) { float freq = scorer.sloppyFreq(); SimScorer docScorer = similarity.simScorer(simWeight, context); Explanation freqExplanation = Explanation.match(freq, "phraseFreq=" + freq); Explanation scoreExplanation = docScorer.explain(doc, freqExplanation); return Explanation.match(scoreExplanation.getValue(), "weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:", scoreExplanation); } } return Explanation.noMatch("no matching term"); } }
@Override public void extractTerms(Set<Term> terms) { for (final SpanWeight w: subWeights) { w.extractTerms(terms); } }