@Override public String getField() { return query.getField(); }
@Override public Query rewrite(IndexReader reader) throws IOException { SpanQuery rewrittenInclude = (SpanQuery) include.rewrite(reader); SpanQuery rewrittenExclude = (SpanQuery) exclude.rewrite(reader); if (rewrittenInclude != include || rewrittenExclude != exclude) { return new SpanNotQuery(rewrittenInclude, rewrittenExclude, pre, post); } return super.rewrite(reader); } /** Returns true iff <code>o</code> is equal to this. */
public Scorer scorer(IndexReader reader) throws IOException { return new SpanScorer(query.getSpans(reader), this, query.getSimilarity(searcher), reader.norms(query.getField())); }
@Override public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException { return query.createWeight(searcher, needsScores, SpanBoostQuery.this.boost * boost); }
public float sumOfSquaredWeights() throws IOException { idf = this.query.getSimilarity(searcher).idf(terms, searcher); queryWeight = idf * query.getBoost(); // compute query weight return queryWeight * queryWeight; // square it }
@Override public float getBoost() { // overridden to remove the deprecation warning return super.getBoost(); }
public Spans getSpans(final IndexReader reader) throws IOException { return new Spans() { private Spans spans = match.getSpans(reader); public boolean next() throws IOException { while (spans.next()) { // scan to next match if (end() <= end) return true; } return false; } public boolean skipTo(int target) throws IOException { if (!spans.skipTo(target)) return false; if (spans.end() <= end) // there is a match return true; return next(); // scan to next match } public int doc() { return spans.doc(); } public int start() { return spans.start(); } public int end() { return spans.end(); } public String toString() { return "spans(" + SpanFirstQuery.this.toString() + ")"; } }; }
public Spans getSpans(final IndexReader reader) throws IOException { return new PayloadSpans() { private PayloadSpans includeSpans = include.getPayloadSpans(reader); private boolean moreInclude = true; private Spans excludeSpans = exclude.getSpans(reader); private boolean moreExclude = excludeSpans.next();
@Override public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException { return maskedQuery.createWeight(searcher, needsScores, boost); }
@Override public float getBoost() { // overridden to remove the deprecation warning return super.getBoost(); }
@Override public String getField() { return match.getField(); }