mirror of https://github.com/apache/lucene.git
SOLR-6037: Fixed incorrect max/sum/stddev for Date fields in StatsComponent
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1591800 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4de244e214
commit
6821905d24
|
@ -126,6 +126,9 @@ Bug Fixes
|
|||
* SOLR-6030: Use System.nanoTime() instead of currentTimeInMills() in LRUCache.warm.
|
||||
(Tomás Fernández Löbbe via shalin)
|
||||
|
||||
* SOLR-6037: Fixed incorrect max/sum/stddev for Date fields in StatsComponent
|
||||
(Brett Lucey, hossman)
|
||||
|
||||
Other Changes
|
||||
---------------------
|
||||
|
||||
|
|
|
@ -390,7 +390,7 @@ class EnumStatsValues extends AbstractStatsValues<EnumFieldValue> {
|
|||
*/
|
||||
class DateStatsValues extends AbstractStatsValues<Date> {
|
||||
|
||||
private long sum = -1;
|
||||
private long sum = 0;
|
||||
double sumOfSquares = 0;
|
||||
|
||||
public DateStatsValues(SchemaField sf, boolean calcDistinct) {
|
||||
|
@ -433,10 +433,10 @@ class DateStatsValues extends AbstractStatsValues<Date> {
|
|||
*/
|
||||
@Override
|
||||
protected void updateMinMax(Date min, Date max) {
|
||||
if(this.min==null || this.min.after(min)) {
|
||||
if(null != min && (this.min==null || this.min.after(min))) {
|
||||
this.min = min;
|
||||
}
|
||||
if(this.max==null || this.max.before(min)) {
|
||||
if(null != max && (this.max==null || this.max.before(max))) {
|
||||
this.max = max;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,7 +264,17 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
|
|||
// test field that is valid in schema and missing in some shards
|
||||
query("q","*:*", "rows",100, "facet","true", "facet.field",oddField, "facet.mincount",2);
|
||||
|
||||
query("q","*:*", "sort",i1+" desc", "stats", "true", "stats.field", "stats_dt");
|
||||
query("q","*:*", "sort",i1+" desc", "stats", "true", "stats.field", i1);
|
||||
query("q","*:*", "sort",i1+" desc", "stats", "true", "stats.field", tdate_a);
|
||||
query("q","*:*", "sort",i1+" desc", "stats", "true", "stats.field", tdate_b);
|
||||
|
||||
handle.put("stats_fields", UNORDERED);
|
||||
query("q","*:*", "sort",i1+" desc", "stats", "true",
|
||||
"stats.field", "stats_dt",
|
||||
"stats.field", i1,
|
||||
"stats.field", tdate_a,
|
||||
"stats.field", tdate_b);
|
||||
|
||||
/*** TODO: the failure may come back in "exception"
|
||||
try {
|
||||
|
@ -417,7 +427,12 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
|
|||
del("*:*"); // delete all docs and test stats request
|
||||
commit();
|
||||
try {
|
||||
query("q", "*:*", "stats", "true", "stats.field", "stats_dt", "stats.calcdistinct", "true");
|
||||
query("q", "*:*", "stats", "true",
|
||||
"stats.field", "stats_dt",
|
||||
"stats.field", i1,
|
||||
"stats.field", tdate_a,
|
||||
"stats.field", tdate_b,
|
||||
"stats.calcdistinct", "true");
|
||||
} catch (Exception e) {
|
||||
log.error("Exception on distrib stats request on empty index", e);
|
||||
fail("NullPointerException with stats request on empty index");
|
||||
|
|
Loading…
Reference in New Issue