下面列出了怎么用org.apache.lucene.search.spans.FilterSpans的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public Spans getSpans(final LeafReaderContext context, Postings requiredPostings) throws IOException {
final PayloadChecker collector = new PayloadChecker();
Spans matchSpans = matchWeight.getSpans(context, requiredPostings.atLeast(Postings.PAYLOADS));
return (matchSpans == null) ? null : new FilterSpans(matchSpans) {
@Override
protected AcceptStatus accept(Spans candidate) throws IOException {
collector.reset();
candidate.collect(collector);
return collector.match();
}
};
}
@Override
public Spans getSpans(final LeafReaderContext context, Postings requiredPostings) throws IOException {
final PayloadChecker collector = new PayloadChecker();
Spans matchSpans = matchWeight.getSpans(context, requiredPostings.atLeast(Postings.PAYLOADS));
return (matchSpans == null) ? null : new FilterSpans(matchSpans) {
@Override
protected AcceptStatus accept(Spans candidate) throws IOException {
collector.reset();
candidate.collect(collector);
return collector.match();
}
};
}