Java Code Examples for org.apache.lucene.search.spans.FilterSpans

The following examples show how to use org.apache.lucene.search.spans.FilterSpans. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: lucene-solr   Source File: SpanPayloadCheckQuery.java    License: Apache License 2.0 5 votes vote down vote up
@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();
    }
  };
}
 
Example 2
@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();
        }
    };
}