@Override public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException { final TermContext context; final IndexReaderContext topContext = searcher.getTopReaderContext(); if (termContext == null || termContext.wasBuiltFor(topContext) == false) { context = TermContext.build(topContext, term); } else { context = termContext; } return new SpanTermWeight(context, searcher, needsScores ? Collections.singletonMap(term, context) : null, boost); }
@Override public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException { final TermContext context; final IndexReaderContext topContext = searcher.getTopReaderContext(); if (termContext == null || termContext.topReaderContext != topContext) { context = TermContext.build(topContext, term); } else { context = termContext; } return new SpanTermWeight(context, searcher, needsScores ? Collections.singletonMap(term, context) : null); }
@Override public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException { final TermContext context; final IndexReaderContext topContext = searcher.getTopReaderContext(); if (termContext == null || termContext.wasBuiltFor(topContext) == false) { context = TermContext.build(topContext, term); } else { context = termContext; } return new SpanTermWeight(context, searcher, needsScores ? Collections.singletonMap(term, context) : null); }
@Override public BLSpanWeight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException { final TermContext context; final IndexReaderContext topContext = searcher.getTopReaderContext(); if (termContext == null || termContext.topReaderContext != topContext) { context = TermContext.build(topContext, query.getTerm()); } else { context = termContext; } Map<Term, TermContext> contexts = needsScores ? Collections.singletonMap(query.getTerm(), context) : null; final SpanTermWeight weight = query.new SpanTermWeight(context, searcher, contexts); return new BLSpanWeight(this, searcher, contexts) { @Override public void extractTermContexts(Map<Term, TermContext> contexts) { weight.extractTermContexts(contexts); } @Override public BLSpans getSpans(LeafReaderContext ctx, Postings requiredPostings) throws IOException { Spans spans = weight.getSpans(ctx, requiredPostings); return spans == null ? null : new BLSpansWrapper(spans); } @Override public void extractTerms(Set<Term> terms) { weight.extractTerms(terms); } }; }
@Override public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException { final TermContext context; final IndexReaderContext topContext = searcher.getTopReaderContext(); if (termContext == null || termContext.wasBuiltFor(topContext) == false) { context = TermContext.build(topContext, term); } else { context = termContext; } return new SpanTermWeight(context, searcher, needsScores ? Collections.singletonMap(term, context) : null, boost); }