diff --git a/source/java/org/alfresco/repo/search/impl/lucene/SolrJSONResultSet.java b/source/java/org/alfresco/repo/search/impl/lucene/SolrJSONResultSet.java
index b5a532ebea..2b7c3cc5d5 100644
--- a/source/java/org/alfresco/repo/search/impl/lucene/SolrJSONResultSet.java
+++ b/source/java/org/alfresco/repo/search/impl/lucene/SolrJSONResultSet.java
@@ -32,6 +32,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.stream.Collectors;
import org.alfresco.repo.domain.node.NodeDAO;
@@ -39,8 +40,10 @@ import org.alfresco.repo.search.SimpleResultSetMetaData;
import org.alfresco.repo.search.impl.solr.facet.facetsresponse.GenericBucket;
import org.alfresco.repo.search.impl.solr.facet.facetsresponse.GenericFacetResponse;
import org.alfresco.repo.search.impl.solr.facet.facetsresponse.GenericFacetResponse.FACET_TYPE;
+import org.alfresco.repo.search.impl.solr.facet.facetsresponse.ListMetric;
import org.alfresco.repo.search.impl.solr.facet.facetsresponse.Metric;
import org.alfresco.repo.search.impl.solr.facet.facetsresponse.Metric.METRIC_TYPE;
+import org.alfresco.repo.search.impl.solr.facet.facetsresponse.PercentileMetric;
import org.alfresco.repo.search.impl.solr.facet.facetsresponse.SimpleMetric;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -415,12 +418,21 @@ public class SolrJSONResultSet implements ResultSet, JSONResult
{
return metrics.entrySet().stream().map(aStat -> {
METRIC_TYPE metricType = METRIC_TYPE.valueOf(aStat.getKey());
+ Object val = aStat.getValue();
+ if (JSONObject.NULL.equals(val)) return null;
+
switch (metricType)
{
+ case distinctValues:
+ return new ListMetric(metricType, val);
+ case percentiles:
+ return new PercentileMetric(metricType, val);
+ case mean:
+ if ("NaN".equals(String.valueOf(val))) return null; //else fall through
default:
- return new SimpleMetric(metricType, String.valueOf(aStat.getValue()));
+ return new SimpleMetric(metricType, val);
}
- }).collect(Collectors.toList());
+ }).filter(Objects::nonNull).collect(Collectors.toList());
}
return Collections.emptyList();
}
diff --git a/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/ListMetric.java b/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/ListMetric.java
new file mode 100644
index 0000000000..83f49111cb
--- /dev/null
+++ b/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/ListMetric.java
@@ -0,0 +1,81 @@
+/*-
+ * #%L
+ * Alfresco Repository
+ * %%
+ * Copyright (C) 2005 - 2017 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
+package org.alfresco.repo.search.impl.solr.facet.facetsresponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.json.JSONArray;
+import org.json.JSONException;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A metric with one value
+ */
+public class ListMetric implements Metric
+{
+ private static Log logger = LogFactory.getLog(ListMetric.class);
+ private final METRIC_TYPE type;
+ private final Map value = new HashMap<>(1);
+
+ public ListMetric(METRIC_TYPE type, Object val)
+ {
+ this.type = type;
+ try
+ {
+ JSONArray jsonArray = (JSONArray) val;
+ List