2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 namespace Mono.Lucene.Net.Search
23 /// <summary> A Filter that restricts search results to a range of values in a given
26 /// <p/>This filter matches the documents looking for terms that fall into the
27 /// supplied range according to {@link String#compareTo(String)}. It is not intended
28 /// for numerical ranges, use {@link NumericRangeFilter} instead.
30 /// <p/>If you construct a large number of range filters with different ranges but on the
31 /// same field, {@link FieldCacheRangeFilter} may have significantly better performance.
36 public class TermRangeFilter:MultiTermQueryWrapperFilter
39 /// <param name="fieldName">The field this range applies to
41 /// <param name="lowerTerm">The lower bound on this range
43 /// <param name="upperTerm">The upper bound on this range
45 /// <param name="includeLower">Does this range include the lower bound?
47 /// <param name="includeUpper">Does this range include the upper bound?
49 /// <throws> IllegalArgumentException if both terms are null or if </throws>
50 /// <summary> lowerTerm is null and includeLower is true (similar for upperTerm
53 public TermRangeFilter(System.String fieldName, System.String lowerTerm, System.String upperTerm, bool includeLower, bool includeUpper):base(new TermRangeQuery(fieldName, lowerTerm, upperTerm, includeLower, includeUpper))
57 /// <summary> <strong>WARNING:</strong> Using this constructor and supplying a non-null
58 /// value in the <code>collator</code> parameter will cause every single
59 /// index Term in the Field referenced by lowerTerm and/or upperTerm to be
60 /// examined. Depending on the number of index Terms in this Field, the
61 /// operation could be very slow.
64 /// <param name="lowerTerm">The lower bound on this range
66 /// <param name="upperTerm">The upper bound on this range
68 /// <param name="includeLower">Does this range include the lower bound?
70 /// <param name="includeUpper">Does this range include the upper bound?
72 /// <param name="collator">The collator to use when determining range inclusion; set
73 /// to null to use Unicode code point ordering instead of collation.
75 /// <throws> IllegalArgumentException if both terms are null or if </throws>
76 /// <summary> lowerTerm is null and includeLower is true (similar for upperTerm
79 public TermRangeFilter(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))
83 /// <summary> Constructs a filter for field <code>fieldName</code> matching
84 /// less than or equal to <code>upperTerm</code>.
86 public static TermRangeFilter Less(System.String fieldName, System.String upperTerm)
88 return new TermRangeFilter(fieldName, null, upperTerm, false, true);
91 /// <summary> Constructs a filter for field <code>fieldName</code> matching
92 /// greater than or equal to <code>lowerTerm</code>.
94 public static TermRangeFilter More(System.String fieldName, System.String lowerTerm)
96 return new TermRangeFilter(fieldName, lowerTerm, null, true, false);
99 /// <summary>Returns the field name for this filter </summary>
100 public virtual System.String GetField()
102 return ((TermRangeQuery) query).GetField();
105 /// <summary>Returns the lower value of this range filter </summary>
106 public virtual System.String GetLowerTerm()
108 return ((TermRangeQuery) query).GetLowerTerm();
111 /// <summary>Returns the upper value of this range filter </summary>
112 public virtual System.String GetUpperTerm()
114 return ((TermRangeQuery) query).GetUpperTerm();
117 /// <summary>Returns <code>true</code> if the lower endpoint is inclusive </summary>
118 public virtual bool IncludesLower()
120 return ((TermRangeQuery) query).IncludesLower();
123 /// <summary>Returns <code>true</code> if the upper endpoint is inclusive </summary>
124 public virtual bool IncludesUpper()
126 return ((TermRangeQuery) query).IncludesUpper();
129 /// <summary>Returns the collator used to determine range inclusion, if any. </summary>
130 public virtual System.Globalization.CompareInfo GetCollator()
132 return ((TermRangeQuery) query).GetCollator();