/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ using System; namespace Lucene.Net.Search { /// A Filter that restricts search results to a range of values in a given /// field. /// ///

This filter matches the documents looking for terms that fall into the /// supplied range according to {@link String#compareTo(String)}. It is not intended /// for numerical ranges, use {@link NumericRangeFilter} instead. /// ///

If you construct a large number of range filters with different ranges but on the /// same field, {@link FieldCacheRangeFilter} may have significantly better performance. /// ///

/// Use {@link TermRangeFilter} for term ranges or /// {@link NumericRangeFilter} for numeric ranges instead. /// This class will be removed in Lucene 3.0. /// [Obsolete("Use TermRangeFilter for term ranges or NumericRangeFilter for numeric ranges instead. This class will be removed in Lucene 3.0")] [Serializable] public class RangeFilter:MultiTermQueryWrapperFilter { /// The field this range applies to /// /// The lower bound on this range /// /// The upper bound on this range /// /// Does this range include the lower bound? /// /// Does this range include the upper bound? /// /// IllegalArgumentException if both terms are null or if /// lowerTerm is null and includeLower is true (similar for upperTerm /// and includeUpper) /// public RangeFilter(System.String fieldName, System.String lowerTerm, System.String upperTerm, bool includeLower, bool includeUpper):base(new TermRangeQuery(fieldName, lowerTerm, upperTerm, includeLower, includeUpper)) { } /// WARNING: Using this constructor and supplying a non-null /// value in the collator parameter will cause every single /// index Term in the Field referenced by lowerTerm and/or upperTerm to be /// examined. Depending on the number of index Terms in this Field, the /// operation could be very slow. /// /// /// The lower bound on this range /// /// The upper bound on this range /// /// Does this range include the lower bound? /// /// Does this range include the upper bound? /// /// The collator to use when determining range inclusion; set /// to null to use Unicode code point ordering instead of collation. /// /// IllegalArgumentException if both terms are null or if /// lowerTerm is null and includeLower is true (similar for upperTerm /// and includeUpper) /// public RangeFilter(System.String fieldName, System.String lowerTerm, System.String upperTerm, bool includeLower, bool includeUpper, System.Globalization.CompareInfo collator):base(new TermRangeQuery(fieldName, lowerTerm, upperTerm, includeLower, includeUpper, collator)) { } /// Constructs a filter for field fieldName matching /// less than or equal to upperTerm. /// public static RangeFilter Less(System.String fieldName, System.String upperTerm) { return new RangeFilter(fieldName, null, upperTerm, false, true); } /// Constructs a filter for field fieldName matching /// greater than or equal to lowerTerm. /// public static RangeFilter More(System.String fieldName, System.String lowerTerm) { return new RangeFilter(fieldName, lowerTerm, null, true, false); } } }