diff --git a/src/java/org/apache/lucene/search/FieldCacheRangeFilter.java b/src/java/org/apache/lucene/search/FieldCacheRangeFilter.java index eecf7b1902f..6efac81e905 100644 --- a/src/java/org/apache/lucene/search/FieldCacheRangeFilter.java +++ b/src/java/org/apache/lucene/search/FieldCacheRangeFilter.java @@ -61,8 +61,6 @@ public abstract class FieldCacheRangeFilter extends Filter { final boolean includeUpper; private FieldCacheRangeFilter(String field, FieldCache.Parser parser, Object lowerVal, Object upperVal, boolean includeLower, boolean includeUpper) { - if (lowerVal == null && upperVal == null) - throw new IllegalArgumentException("At least one value must be non-null"); this.field = field; this.parser = parser; this.lowerVal = lowerVal; diff --git a/src/java/org/apache/lucene/search/NumericRangeQuery.java b/src/java/org/apache/lucene/search/NumericRangeQuery.java index dc5cc09cb8d..c34d19872cb 100644 --- a/src/java/org/apache/lucene/search/NumericRangeQuery.java +++ b/src/java/org/apache/lucene/search/NumericRangeQuery.java @@ -127,8 +127,6 @@ public final class NumericRangeQuery extends MultiTermQuery { Number min, Number max, final boolean minInclusive, final boolean maxInclusive ) { assert (valSize == 32 || valSize == 64); - if (min == null && max == null) - throw new IllegalArgumentException("At least one value must be non-null"); if (precisionStep < 1 || precisionStep > valSize) throw new IllegalArgumentException("precisionStep may only be 1.."+valSize); this.field = field.intern(); diff --git a/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java b/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java index b72c2763fa2..afeca137203 100644 --- a/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java +++ b/src/test/org/apache/lucene/search/TestFieldCacheRangeFilter.java @@ -87,6 +87,9 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter { // unbounded id + result = search.search(q,FieldCacheRangeFilter.newStringRange("id",null,null,T,T), numDocs).scoreDocs; + assertEquals("find all", numDocs, result.length); + result = search.search(q,FieldCacheRangeFilter.newStringRange("id",minIP,null,T,F), numDocs).scoreDocs; assertEquals("min and up", numDocs, result.length); @@ -230,6 +233,9 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter { // unbounded id + result = search.search(q,FieldCacheRangeFilter.newShortRange("id",null,null,T,T), numDocs).scoreDocs; + assertEquals("find all", numDocs, result.length); + result = search.search(q,FieldCacheRangeFilter.newShortRange("id",minIdO,null,T,F), numDocs).scoreDocs; assertEquals("min and up", numDocs, result.length); @@ -317,6 +323,9 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter { // unbounded id + result = search.search(q,FieldCacheRangeFilter.newIntRange("id",null,null,T,T), numDocs).scoreDocs; + assertEquals("find all", numDocs, result.length); + result = search.search(q,FieldCacheRangeFilter.newIntRange("id",minIdO,null,T,F), numDocs).scoreDocs; assertEquals("min and up", numDocs, result.length); @@ -404,6 +413,9 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter { // unbounded id + result = search.search(q,FieldCacheRangeFilter.newLongRange("id",null,null,T,T), numDocs).scoreDocs; + assertEquals("find all", numDocs, result.length); + result = search.search(q,FieldCacheRangeFilter.newLongRange("id",minIdO,null,T,F), numDocs).scoreDocs; assertEquals("min and up", numDocs, result.length); @@ -475,6 +487,8 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter { result = search.search(q,FieldCacheRangeFilter.newFloatRange("id",medIdO,null,F,F), numDocs).scoreDocs; count += result.length; assertEquals("sum of two concenatted ranges", numDocs, count); + result = search.search(q,FieldCacheRangeFilter.newFloatRange("id",null,null,T,T), numDocs).scoreDocs; + assertEquals("find all", numDocs, result.length); result = search.search(q,FieldCacheRangeFilter.newFloatRange("id",new Float(Float.POSITIVE_INFINITY),null,F,F), numDocs).scoreDocs; assertEquals("infinity special case", 0, result.length); result = search.search(q,FieldCacheRangeFilter.newFloatRange("id",null,new Float(Float.NEGATIVE_INFINITY),F,F), numDocs).scoreDocs; @@ -501,6 +515,8 @@ public class TestFieldCacheRangeFilter extends BaseTestRangeFilter { result = search.search(q,FieldCacheRangeFilter.newDoubleRange("id",medIdO,null,F,F), numDocs).scoreDocs; count += result.length; assertEquals("sum of two concenatted ranges", numDocs, count); + result = search.search(q,FieldCacheRangeFilter.newDoubleRange("id",null,null,T,T), numDocs).scoreDocs; + assertEquals("find all", numDocs, result.length); result = search.search(q,FieldCacheRangeFilter.newDoubleRange("id",new Double(Double.POSITIVE_INFINITY),null,F,F), numDocs).scoreDocs; assertEquals("infinity special case", 0, result.length); result = search.search(q,FieldCacheRangeFilter.newDoubleRange("id",null, new Double(Double.NEGATIVE_INFINITY),F,F), numDocs).scoreDocs; diff --git a/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java b/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java index a4f05ab0d5c..6c4c11353b1 100644 --- a/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java +++ b/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java @@ -391,6 +391,7 @@ public class TestNumericRangeQuery32 extends LuceneTestCase { QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test4", 4, new Integer(10), new Integer(20), false, false)); QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test5", 4, new Integer(10), null, true, true)); QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test6", 4, null, new Integer(20), true, true)); + QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test7", 4, null, null, true, true)); QueryUtils.checkEqual( NumericRangeQuery.newIntRange("test8", 4, new Integer(10), new Integer(20), true, true), NumericRangeQuery.newIntRange("test8", 4, new Integer(10), new Integer(20), true, true) diff --git a/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java b/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java index ffba3edbb9e..1415b0ccd08 100644 --- a/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java +++ b/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java @@ -391,6 +391,7 @@ public class TestNumericRangeQuery64 extends LuceneTestCase { QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test4", 4, new Long(10L), new Long(20L), false, false)); QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test5", 4, new Long(10L), null, true, true)); QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test6", 4, null, new Long(20L), true, true)); + QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test7", 4, null, null, true, true)); QueryUtils.checkEqual( NumericRangeQuery.newLongRange("test8", 4, new Long(10L), new Long(20L), true, true), NumericRangeQuery.newLongRange("test8", 4, new Long(10L), new Long(20L), true, true)