mirror of https://github.com/apache/lucene.git
LUCENE-4235: Remove enforcing of Filter rewrite for NRQ queries
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1363049 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
24dae70408
commit
cee33695d3
|
@ -54,6 +54,9 @@ Optimizations
|
||||||
* LUCENE-4184: Performance improvements to the aligned packed bits impl.
|
* LUCENE-4184: Performance improvements to the aligned packed bits impl.
|
||||||
(Toke Eskildsen, Adrien Grand)
|
(Toke Eskildsen, Adrien Grand)
|
||||||
|
|
||||||
|
* LUCENE-4235: Remove enforcing of Filter rewrite for NRQ queries.
|
||||||
|
(Uwe Schindler)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
|
|
||||||
* LUCENE-4176: Fix AnalyzingQueryParser to analyze range endpoints as bytes,
|
* LUCENE-4176: Fix AnalyzingQueryParser to analyze range endpoints as bytes,
|
||||||
|
|
|
@ -173,35 +173,6 @@ public final class NumericRangeQuery<T extends Number> extends MultiTermQuery {
|
||||||
this.max = max;
|
this.max = max;
|
||||||
this.minInclusive = minInclusive;
|
this.minInclusive = minInclusive;
|
||||||
this.maxInclusive = maxInclusive;
|
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<T extends Number> extends MultiTermQuery {
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
protected TermsEnum getTermsEnum(final Terms terms, AttributeSource atts) throws IOException {
|
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
|
// very strange: java.lang.Number itsself is not Comparable, but all subclasses used here are
|
||||||
return (min != null && max != null && ((Comparable<T>) min).compareTo(max) > 0) ?
|
if (min != null && max != null && ((Comparable<T>) min).compareTo(max) > 0) {
|
||||||
TermsEnum.EMPTY :
|
return TermsEnum.EMPTY;
|
||||||
new NumericRangeTermsEnum(terms.iterator(null));
|
}
|
||||||
|
return new NumericRangeTermsEnum(terms.iterator(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns <code>true</code> if the lower endpoint is inclusive */
|
/** Returns <code>true</code> if the lower endpoint is inclusive */
|
||||||
|
|
|
@ -211,7 +211,6 @@ public class TestNumericRangeQuery32 extends LuceneTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testOneMatchQuery() throws Exception {
|
public void testOneMatchQuery() throws Exception {
|
||||||
NumericRangeQuery<Integer> q = NumericRangeQuery.newIntRange("ascfield8", 8, 1000, 1000, true, true);
|
NumericRangeQuery<Integer> q = NumericRangeQuery.newIntRange("ascfield8", 8, 1000, 1000, true, true);
|
||||||
assertSame(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE, q.getRewriteMethod());
|
|
||||||
TopDocs topDocs = searcher.search(q, noDocs);
|
TopDocs topDocs = searcher.search(q, noDocs);
|
||||||
ScoreDoc[] sd = topDocs.scoreDocs;
|
ScoreDoc[] sd = topDocs.scoreDocs;
|
||||||
assertNotNull(sd);
|
assertNotNull(sd);
|
||||||
|
|
|
@ -226,7 +226,6 @@ public class TestNumericRangeQuery64 extends LuceneTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testOneMatchQuery() throws Exception {
|
public void testOneMatchQuery() throws Exception {
|
||||||
NumericRangeQuery<Long> q = NumericRangeQuery.newLongRange("ascfield8", 8, 1000L, 1000L, true, true);
|
NumericRangeQuery<Long> q = NumericRangeQuery.newLongRange("ascfield8", 8, 1000L, 1000L, true, true);
|
||||||
assertSame(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE, q.getRewriteMethod());
|
|
||||||
TopDocs topDocs = searcher.search(q, noDocs);
|
TopDocs topDocs = searcher.search(q, noDocs);
|
||||||
ScoreDoc[] sd = topDocs.scoreDocs;
|
ScoreDoc[] sd = topDocs.scoreDocs;
|
||||||
assertNotNull(sd);
|
assertNotNull(sd);
|
||||||
|
|
Loading…
Reference in New Issue