|
Lucene example source code file (SpanQueryFilter.java)
The Lucene SpanQueryFilter.java source codepackage org.apache.lucene.search; /** * Copyright 2007 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.search.spans.Spans; import org.apache.lucene.util.OpenBitSet; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * Constrains search results to only match those which also match a provided * query. Also provides position information about where each document matches * at the cost of extra space compared with the QueryWrapperFilter. * There is an added cost to this above what is stored in a {@link QueryWrapperFilter}. Namely, * the position information for each matching document is stored. * <p/> * This filter does not cache. See the {@link org.apache.lucene.search.CachingSpanFilter} for a wrapper that * caches. */ public class SpanQueryFilter extends SpanFilter { protected SpanQuery query; protected SpanQueryFilter() { } /** Constructs a filter which only matches documents matching * <code>query. * @param query The {@link org.apache.lucene.search.spans.SpanQuery} to use as the basis for the Filter. */ public SpanQueryFilter(SpanQuery query) { this.query = query; } @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { SpanFilterResult result = bitSpans(reader); return result.getDocIdSet(); } @Override public SpanFilterResult bitSpans(IndexReader reader) throws IOException { final OpenBitSet bits = new OpenBitSet(reader.maxDoc()); Spans spans = query.getSpans(reader); List<SpanFilterResult.PositionInfo> tmp = new ArrayList Other Lucene examples (source code examples)Here is a short list of links related to this Lucene SpanQueryFilter.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.