Methods Summary |
---|
public org.apache.lucene.search.spans.SpanQuery | getExclude()Return the SpanQuery whose matches must not overlap those returned. return exclude;
|
public java.lang.String | getField() return include.getField();
|
public org.apache.lucene.search.spans.SpanQuery | getInclude()Return the SpanQuery whose matches are filtered. return include;
|
public org.apache.lucene.search.spans.Spans | getSpans(org.apache.lucene.index.IndexReader reader)
return new Spans() {
private Spans includeSpans = include.getSpans(reader);
private boolean moreInclude = true;
private Spans excludeSpans = exclude.getSpans(reader);
private boolean moreExclude = true;
public boolean next() throws IOException {
if (moreInclude) // move to next include
moreInclude = includeSpans.next();
while (moreInclude && moreExclude) {
if (includeSpans.doc() > excludeSpans.doc()) // skip exclude
moreExclude = excludeSpans.skipTo(includeSpans.doc());
while (moreExclude // while exclude is before
&& includeSpans.doc() == excludeSpans.doc()
&& excludeSpans.end() <= includeSpans.start()) {
moreExclude = excludeSpans.next(); // increment exclude
}
if (!moreExclude // if no intersection
|| includeSpans.doc() != excludeSpans.doc()
|| includeSpans.end() <= excludeSpans.start())
break; // we found a match
moreInclude = includeSpans.next(); // intersected: keep scanning
}
return moreInclude;
}
public boolean skipTo(int target) throws IOException {
if (moreInclude) // skip include
moreInclude = includeSpans.skipTo(target);
if (!moreInclude)
return false;
if (moreExclude // skip exclude
&& includeSpans.doc() > excludeSpans.doc())
moreExclude = excludeSpans.skipTo(includeSpans.doc());
while (moreExclude // while exclude is before
&& includeSpans.doc() == excludeSpans.doc()
&& excludeSpans.end() <= includeSpans.start()) {
moreExclude = excludeSpans.next(); // increment exclude
}
if (!moreExclude // if no intersection
|| includeSpans.doc() != excludeSpans.doc()
|| includeSpans.end() <= excludeSpans.start())
return true; // we found a match
return next(); // scan to next match
}
public int doc() { return includeSpans.doc(); }
public int start() { return includeSpans.start(); }
public int end() { return includeSpans.end(); }
public String toString() {
return "spans(" + SpanNotQuery.this.toString() + ")";
}
};
|
public java.util.Collection | getTerms() return include.getTerms();
|
public java.lang.String | toString(java.lang.String field)
StringBuffer buffer = new StringBuffer();
buffer.append("spanNot(");
buffer.append(include.toString(field));
buffer.append(", ");
buffer.append(exclude.toString(field));
buffer.append(")");
return buffer.toString();
|