diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 0d4bcfcfa05..c9fdf4e1ada 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -54,6 +54,9 @@ Optimizations * LUCENE-4184: Performance improvements to the aligned packed bits impl. (Toke Eskildsen, Adrien Grand) +* LUCENE-4235: Remove enforcing of Filter rewrite for NRQ queries. + (Uwe Schindler) + Bug Fixes * LUCENE-4176: Fix AnalyzingQueryParser to analyze range endpoints as bytes, diff --git a/lucene/core/src/java/org/apache/lucene/search/NumericRangeQuery.java b/lucene/core/src/java/org/apache/lucene/search/NumericRangeQuery.java index 24fa0fb36c1..8dbb146507f 100644 --- a/lucene/core/src/java/org/apache/lucene/search/NumericRangeQuery.java +++ b/lucene/core/src/java/org/apache/lucene/search/NumericRangeQuery.java @@ -173,35 +173,6 @@ public final class NumericRangeQuery extends MultiTermQuery { this.max = max; this.minInclusive = minInclusive; this.maxInclusive = maxInclusive; - - // For bigger precisionSteps this query likely - // hits too many terms, so set to CONSTANT_SCORE_FILTER right off - // (especially as the FilteredTermsEnum is costly if wasted only for AUTO tests because it - // creates new enums from IndexReader for each sub-range) - switch (dataType) { - case LONG: - case DOUBLE: - setRewriteMethod( (precisionStep > 6) ? - CONSTANT_SCORE_FILTER_REWRITE : - CONSTANT_SCORE_AUTO_REWRITE_DEFAULT - ); - break; - case INT: - case FLOAT: - setRewriteMethod( (precisionStep > 8) ? - CONSTANT_SCORE_FILTER_REWRITE : - CONSTANT_SCORE_AUTO_REWRITE_DEFAULT - ); - break; - default: - // should never happen - throw new IllegalArgumentException("Invalid numeric NumericType"); - } - - // shortcut if upper bound == lower bound - if (min != null && min.equals(max)) { - setRewriteMethod(CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE); - } } /** @@ -319,9 +290,10 @@ public final class NumericRangeQuery extends MultiTermQuery { @Override @SuppressWarnings("unchecked") protected TermsEnum getTermsEnum(final Terms terms, AttributeSource atts) throws IOException { // very strange: java.lang.Number itsself is not Comparable, but all subclasses used here are - return (min != null && max != null && ((Comparable) min).compareTo(max) > 0) ? - TermsEnum.EMPTY : - new NumericRangeTermsEnum(terms.iterator(null)); + if (min != null && max != null && ((Comparable) min).compareTo(max) > 0) { + return TermsEnum.EMPTY; + } + return new NumericRangeTermsEnum(terms.iterator(null)); } /** Returns true if the lower endpoint is inclusive */ diff --git a/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java b/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java index 456ec914cb3..b5765fd9c52 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java @@ -211,7 +211,6 @@ public class TestNumericRangeQuery32 extends LuceneTestCase { @Test public void testOneMatchQuery() throws Exception { NumericRangeQuery q = NumericRangeQuery.newIntRange("ascfield8", 8, 1000, 1000, true, true); - assertSame(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE, q.getRewriteMethod()); TopDocs topDocs = searcher.search(q, noDocs); ScoreDoc[] sd = topDocs.scoreDocs; assertNotNull(sd); diff --git a/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java b/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java index 82dc587a1cb..fb307355269 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java @@ -226,7 +226,6 @@ public class TestNumericRangeQuery64 extends LuceneTestCase { @Test public void testOneMatchQuery() throws Exception { NumericRangeQuery q = NumericRangeQuery.newLongRange("ascfield8", 8, 1000L, 1000L, true, true); - assertSame(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE, q.getRewriteMethod()); TopDocs topDocs = searcher.search(q, noDocs); ScoreDoc[] sd = topDocs.scoreDocs; assertNotNull(sd);