You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2017/07/25 09:05:54 UTC
[09/50] [abbrv] lucene-solr:feature/autoscaling: SOLR-11057: Fix
overflow in point range queries when querying the type limits
SOLR-11057: Fix overflow in point range queries when querying the type limits
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/beec66ec
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/beec66ec
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/beec66ec
Branch: refs/heads/feature/autoscaling
Commit: beec66ece79bde6fd091fa40b5d2ce08ad65365c
Parents: 67fbd4f
Author: Tomas Fernandez Lobbe <tf...@apache.org>
Authored: Tue Jul 18 14:32:11 2017 -0700
Committer: Tomas Fernandez Lobbe <tf...@apache.org>
Committed: Tue Jul 18 14:32:11 2017 -0700
----------------------------------------------------------------------
solr/CHANGES.txt | 3 ++
.../org/apache/solr/schema/DatePointField.java | 3 ++
.../org/apache/solr/schema/IntPointField.java | 3 ++
.../org/apache/solr/schema/LongPointField.java | 3 ++
.../org/apache/solr/schema/TestPointFields.java | 54 ++++++++++++++++++++
5 files changed, 66 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/beec66ec/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 277ba78..91400f1 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -360,6 +360,9 @@ Bug Fixes
* SOLR-11073: Fix overflow in interval faceting when querying Long limits (e.g. (Long.MAX_VALUE TO Long.MAX_VALUE])
(Tomás Fernández Löbbe)
+* SOLR-11057: Fix overflow in point range queries when querying the type limits
+ (e.g. q=field_i:{Integer.MAX_VALUE TO Integer.MAX_VALUE]) (Tomás Fernández Löbbe)
+
Optimizations
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/beec66ec/solr/core/src/java/org/apache/solr/schema/DatePointField.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/schema/DatePointField.java b/solr/core/src/java/org/apache/solr/schema/DatePointField.java
index ea81ea3..e43f706 100644
--- a/solr/core/src/java/org/apache/solr/schema/DatePointField.java
+++ b/solr/core/src/java/org/apache/solr/schema/DatePointField.java
@@ -27,6 +27,7 @@ import org.apache.lucene.index.IndexableField;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.LongFieldSource;
import org.apache.lucene.queries.function.valuesource.MultiValuedLongFieldSource;
+import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.SortedNumericSelector;
@@ -123,6 +124,7 @@ public class DatePointField extends PointField implements DateValueFieldType {
} else {
actualMin = DateMathParser.parseMath(null, min).getTime();
if (!minInclusive) {
+ if (actualMin == Long.MAX_VALUE) return new MatchNoDocsQuery();
actualMin++;
}
}
@@ -131,6 +133,7 @@ public class DatePointField extends PointField implements DateValueFieldType {
} else {
actualMax = DateMathParser.parseMath(null, max).getTime();
if (!maxInclusive) {
+ if (actualMax == Long.MIN_VALUE) return new MatchNoDocsQuery();
actualMax--;
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/beec66ec/solr/core/src/java/org/apache/solr/schema/IntPointField.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/schema/IntPointField.java b/solr/core/src/java/org/apache/solr/schema/IntPointField.java
index 7d36612..d5e4aec 100644
--- a/solr/core/src/java/org/apache/solr/schema/IntPointField.java
+++ b/solr/core/src/java/org/apache/solr/schema/IntPointField.java
@@ -25,6 +25,7 @@ import org.apache.lucene.index.IndexableField;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.IntFieldSource;
import org.apache.lucene.queries.function.valuesource.MultiValuedIntFieldSource;
+import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.SortedNumericSelector;
@@ -66,6 +67,7 @@ public class IntPointField extends PointField implements IntValueFieldType {
} else {
actualMin = parseIntFromUser(field.getName(), min);
if (!minInclusive) {
+ if (actualMin == Integer.MAX_VALUE) return new MatchNoDocsQuery();
actualMin++;
}
}
@@ -74,6 +76,7 @@ public class IntPointField extends PointField implements IntValueFieldType {
} else {
actualMax = parseIntFromUser(field.getName(), max);
if (!maxInclusive) {
+ if (actualMax == Integer.MIN_VALUE) return new MatchNoDocsQuery();
actualMax--;
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/beec66ec/solr/core/src/java/org/apache/solr/schema/LongPointField.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/schema/LongPointField.java b/solr/core/src/java/org/apache/solr/schema/LongPointField.java
index b2d8a3a..7e3f5e1 100644
--- a/solr/core/src/java/org/apache/solr/schema/LongPointField.java
+++ b/solr/core/src/java/org/apache/solr/schema/LongPointField.java
@@ -25,6 +25,7 @@ import org.apache.lucene.index.IndexableField;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.LongFieldSource;
import org.apache.lucene.queries.function.valuesource.MultiValuedLongFieldSource;
+import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.SortField;
import org.apache.lucene.util.BytesRef;
@@ -65,6 +66,7 @@ public class LongPointField extends PointField implements LongValueFieldType {
} else {
actualMin = parseLongFromUser(field.getName(), min);
if (!minInclusive) {
+ if (actualMin == Long.MAX_VALUE) return new MatchNoDocsQuery();
actualMin++;
}
}
@@ -73,6 +75,7 @@ public class LongPointField extends PointField implements LongValueFieldType {
} else {
actualMax = parseLongFromUser(field.getName(), max);
if (!maxInclusive) {
+ if (actualMax == Long.MIN_VALUE) return new MatchNoDocsQuery();
actualMax--;
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/beec66ec/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
index f8b6971..7aad542 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
@@ -2381,6 +2381,17 @@ public class TestPointFields extends SolrTestCaseJ4 {
assertQ(req("q", fieldName + ":[" + arr[0] + " TO " + arr[i] + "] AND " + fieldName + ":" + arr[0].replace("-", "\\-"), "fl", "id, " + fieldName),
"//*[@numFound='1']");
}
+ if (testLong) {
+ assertQ(req("q", fieldName + ":[" + Long.MIN_VALUE + " TO " + Long.MIN_VALUE + "}", "fl", "id, " + fieldName),
+ "//*[@numFound='0']");
+ assertQ(req("q", fieldName + ":{" + Long.MAX_VALUE + " TO " + Long.MAX_VALUE + "]", "fl", "id, " + fieldName),
+ "//*[@numFound='0']");
+ } else {
+ assertQ(req("q", fieldName + ":[" + Integer.MIN_VALUE + " TO " + Integer.MIN_VALUE + "}", "fl", "id, " + fieldName),
+ "//*[@numFound='0']");
+ assertQ(req("q", fieldName + ":{" + Integer.MAX_VALUE + " TO " + Integer.MAX_VALUE + "]", "fl", "id, " + fieldName),
+ "//*[@numFound='0']");
+ }
}
private void doTestPointFieldFacetField(String nonDocValuesField, String docValuesField, String[] numbers) throws Exception {
@@ -3181,6 +3192,43 @@ public class TestPointFields extends SolrTestCaseJ4 {
assertQ(req("q", fieldName + ":{" + arr[0] + " TO " + arr[i] + "}", "fl", "id, " + fieldName),
"//*[@numFound='" + (Math.max(0, i-1)) + "']");
}
+
+ clearIndex();
+ assertU(adoc("id", "1", fieldName, String.valueOf(Float.MAX_VALUE)));
+ assertU(adoc("id", "2", fieldName, String.valueOf(Float.MIN_VALUE)));
+ assertU(adoc("id", "3", fieldName, String.valueOf(Float.NEGATIVE_INFINITY)));
+ assertU(adoc("id", "4", fieldName, String.valueOf(Float.POSITIVE_INFINITY)));
+ assertU(commit());
+ assertQ(req("q", fieldName + ":[* TO *]", "fl", "id, " + fieldName),
+ "//*[@numFound='4']");
+// TODO: Awaits fix: SOLR-11070
+// assertQ(req("q", fieldName + ":{* TO *}", "fl", "id, " + fieldName),
+// "//*[@numFound='4']");
+ assertQ(req("q", fieldName + ":[" + Float.MIN_VALUE + " TO " + Float.MAX_VALUE + "]", "fl", "id, " + fieldName),
+ "//*[@numFound='2']");
+ assertQ(req("q", fieldName + ":{" + Float.MIN_VALUE + " TO " + Float.MAX_VALUE + "]", "fl", "id, " + fieldName),
+ "//*[@numFound='1']");
+ assertQ(req("q", fieldName + ":[" + Float.MIN_VALUE + " TO " + Float.MAX_VALUE + "}", "fl", "id, " + fieldName),
+ "//*[@numFound='1']");
+ if (testDouble) {
+ assertQ(req("q", fieldName + ":[" + Double.MIN_VALUE + " TO " + Double.MIN_VALUE + "}", "fl", "id, " + fieldName),
+ "//*[@numFound='0']");
+ assertQ(req("q", fieldName + ":{" + Double.MAX_VALUE + " TO " + Double.MAX_VALUE + "]", "fl", "id, " + fieldName),
+ "//*[@numFound='0']");
+ assertQ(req("q", fieldName + ":{" + Double.NEGATIVE_INFINITY + " TO " + Double.NEGATIVE_INFINITY + "]", "fl", "id, " + fieldName),
+ "//*[@numFound='0']");
+ assertQ(req("q", fieldName + ":[" + Double.POSITIVE_INFINITY + " TO " + Double.POSITIVE_INFINITY + "}", "fl", "id, " + fieldName),
+ "//*[@numFound='0']");
+ } else {
+ assertQ(req("q", fieldName + ":[" + Float.MIN_VALUE + " TO " + Float.MIN_VALUE + "}", "fl", "id, " + fieldName),
+ "//*[@numFound='0']");
+ assertQ(req("q", fieldName + ":{" + Float.MAX_VALUE + " TO " + Float.MAX_VALUE + "]", "fl", "id, " + fieldName),
+ "//*[@numFound='0']");
+ assertQ(req("q", fieldName + ":{" + Float.NEGATIVE_INFINITY + " TO " + Float.NEGATIVE_INFINITY + "]", "fl", "id, " + fieldName),
+ "//*[@numFound='0']");
+ assertQ(req("q", fieldName + ":[" + Float.POSITIVE_INFINITY + " TO " + Float.POSITIVE_INFINITY + "}", "fl", "id, " + fieldName),
+ "//*[@numFound='0']");
+ }
}
private void doTestFloatPointFunctionQuery(String field) throws Exception {
@@ -3487,7 +3535,13 @@ public class TestPointFields extends SolrTestCaseJ4 {
ascNegXpathChecks);
clearIndex();
+ assertU(adoc("id", "1", field, "1995-12-31T10:59:59Z"));
+ assertU(adoc("id", "2", field, "1996-12-31T10:59:59Z"));
assertU(commit());
+ assertQ(req("q", field + ":[* TO *]", "fl", "id, " + field),
+ "//*[@numFound='2']");
+ assertQ(req("q", field + ":{* TO *}", "fl", "id, " + field),
+ "//*[@numFound='2']");
}
private void doTestDatePointStats(String field, String dvField, String[] dates) {