1 package org.apache.lucene.search; 2 3 /** 4 * Licensed to the Apache Software Foundation (ASF) under one or more 5 * contributor license agreements. See the NOTICE file distributed with 6 * this work for additional information regarding copyright ownership. 7 * The ASF licenses this file to You under the Apache License, Version 2.0 8 * (the "License"); you may not use this file except in compliance with 9 * the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 import java.io.IOException; 21 22 import org.apache.lucene.index.IndexReader; 23 import org.apache.lucene.util.DocIdBitSet; 24 25 /** 26 * Abstract base class for restricting which documents may 27 * be returned during searching. 28 */ 29 public abstract class Filter implements java.io.Serializable { 30 31 /** 32 * Creates a {@link DocIdSet} enumerating the documents that should be 33 * permitted in search results. <b>NOTE:</b> null can be 34 * returned if no documents are accepted by this Filter. 35 * <p> 36 * Note: This method will be called once per segment in 37 * the index during searching. The returned {@link DocIdSet} 38 * must refer to document IDs for that segment, not for 39 * the top-level reader. 40 * 41 * @param reader a {@link IndexReader} instance opened on the index currently 42 * searched on. Note, it is likely that the provided reader does not 43 * represent the whole underlying index i.e. if the index has more than 44 * one segment the given reader only represents a single segment. 45 * 46 * @return a DocIdSet that provides the documents which should be permitted or 47 * prohibited in search results. <b>NOTE:</b> null can be returned if 48 * no documents will be accepted by this Filter. 49 * 50 * @see DocIdBitSet 51 */ 52 public abstract DocIdSet getDocIdSet(IndexReader reader) throws IOException; 53 }