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

The following examples show how to use org.apache.lucene.search.spans.FilterSpans. 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 File: SpanPayloadCheckQuery.java    From lucene-solr with 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
Source File: CustomSpanPayloadCheckQuery.java    From elasticsearch-plugin-bundle with GNU Affero General Public License v3.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();
        }
    };
}