mirror of https://github.com/apache/lucene.git
Fix for SOLR-3160. Thanks Luca Cavanna!
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1293270 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f29eda768d
commit
8aecefd623
|
@ -354,7 +354,9 @@ class DateStatsValues extends AbstractStatsValues<Date> {
|
|||
*/
|
||||
protected void addTypeSpecificStats(NamedList<Object> res) {
|
||||
res.add("sum", new Date(sum));
|
||||
res.add("mean", new Date(sum / count));
|
||||
if (count > 0) {
|
||||
res.add("mean", new Date(sum / count));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -281,4 +281,62 @@ public class StatsComponentTest extends AbstractSolrTestCase {
|
|||
, "//lst[@name='false']/double[@name='stddev'][.='0.0']"
|
||||
);
|
||||
}
|
||||
|
||||
public void testFieldStatisticsResultsNumericFieldAlwaysMissing() throws Exception {
|
||||
SolrCore core = h.getCore();
|
||||
assertU(adoc("id", "1"));
|
||||
assertU(adoc("id", "2"));
|
||||
assertU(adoc("id", "3"));
|
||||
assertU(adoc("id", "4"));
|
||||
assertU(commit());
|
||||
|
||||
Map<String, String> args = new HashMap<String, String>();
|
||||
args.put(CommonParams.Q, "*:*");
|
||||
args.put(StatsParams.STATS, "true");
|
||||
args.put(StatsParams.STATS_FIELD, "active_i");
|
||||
args.put("indent", "true");
|
||||
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
|
||||
|
||||
assertQ("test string statistics values", req,
|
||||
"//null[@name='active_i'][.='']");
|
||||
}
|
||||
|
||||
public void testFieldStatisticsResultsStringFieldAlwaysMissing() throws Exception {
|
||||
SolrCore core = h.getCore();
|
||||
assertU(adoc("id", "1"));
|
||||
assertU(adoc("id", "2"));
|
||||
assertU(adoc("id", "3"));
|
||||
assertU(adoc("id", "4"));
|
||||
assertU(commit());
|
||||
|
||||
Map<String, String> args = new HashMap<String, String>();
|
||||
args.put(CommonParams.Q, "*:*");
|
||||
args.put(StatsParams.STATS, "true");
|
||||
args.put(StatsParams.STATS_FIELD, "active_s");
|
||||
args.put("indent", "true");
|
||||
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
|
||||
|
||||
assertQ("test string statistics values", req,
|
||||
"//null[@name='active_s'][.='']");
|
||||
}
|
||||
|
||||
//SOLR-3160
|
||||
public void testFieldStatisticsResultsDateFieldAlwaysMissing() throws Exception {
|
||||
SolrCore core = h.getCore();
|
||||
|
||||
assertU(adoc("id", "1"));
|
||||
assertU(adoc("id", "2"));
|
||||
assertU(adoc("id", "3"));
|
||||
assertU(commit());
|
||||
|
||||
Map<String, String> args = new HashMap<String, String>();
|
||||
args.put(CommonParams.Q, "*:*");
|
||||
args.put(StatsParams.STATS, "true");
|
||||
args.put(StatsParams.STATS_FIELD, "active_dt");
|
||||
args.put("indent", "true");
|
||||
SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(args));
|
||||
|
||||
assertQ("test string statistics values", req,
|
||||
"//null[@name='active_dt'][.='']");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue