mirror of https://github.com/apache/lucene.git
SOLR-7800: avg facet function should skip missing values
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1691430 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e8a5ffbea3
commit
58ec4d8824
|
@ -329,6 +329,12 @@ Other Changes
|
|||
* SOLR-7703: Authentication plugin is now loaded using the RessourceLoader.
|
||||
(Avi Digmi via Anshum Gupta)
|
||||
|
||||
* SOLR-7800: JSON Facet API: the avg() facet function now skips missing values
|
||||
rather than treating them as a 0 value. The def() function can be used to
|
||||
treat missing values as 0 if that is desired.
|
||||
Example: facet:{ mean:"avg(def(myfield,0))" }
|
||||
|
||||
|
||||
================== 5.2.1 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
|
||||
|
|
|
@ -348,9 +348,11 @@ class AvgSlotAcc extends DoubleFuncSlotAcc {
|
|||
|
||||
@Override
|
||||
public void collect(int doc, int slotNum) {
|
||||
double val = values.doubleVal(doc); // todo: worth trying to share this value across multiple stats that need it?
|
||||
result[slotNum] += val;
|
||||
counts[slotNum] += 1;
|
||||
double val = values.doubleVal(doc);
|
||||
if (val != 0 || values.exists(doc)) {
|
||||
result[slotNum] += val;
|
||||
counts[slotNum] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
private double avg(double tot, int count) {
|
||||
|
|
|
@ -737,13 +737,13 @@ public class TestJsonFacets extends SolrTestCaseHS {
|
|||
|
||||
// stats at top level
|
||||
client.testJQ(params(p, "q", "*:*"
|
||||
, "json.facet", "{ sum1:'sum(${num_d})', sumsq1:'sumsq(${num_d})', avg1:'avg(${num_d})', min1:'min(${num_d})', max1:'max(${num_d})'" +
|
||||
, "json.facet", "{ sum1:'sum(${num_d})', sumsq1:'sumsq(${num_d})', avg1:'avg(${num_d})', avg2:'avg(def(${num_d},0))', min1:'min(${num_d})', max1:'max(${num_d})'" +
|
||||
", numwhere:'unique(${where_s})', unique_num_i:'unique(${num_i})', unique_num_d:'unique(${num_d})', unique_date:'unique(${date})'" +
|
||||
", where_hll:'hll(${where_s})', hll_num_i:'hll(${num_i})', hll_num_d:'hll(${num_d})', hll_date:'hll(${date})'" +
|
||||
", med:'percentile(${num_d},50)', perc:'percentile(${num_d},0,50.0,100)' }"
|
||||
)
|
||||
, "facets=={ 'count':6, " +
|
||||
"sum1:3.0, sumsq1:247.0, avg1:0.5, min1:-9.0, max1:11.0" +
|
||||
"sum1:3.0, sumsq1:247.0, avg1:0.6, avg2:0.5, min1:-9.0, max1:11.0" +
|
||||
", numwhere:2, unique_num_i:4, unique_num_d:5, unique_date:5" +
|
||||
", where_hll:2, hll_num_i:4, hll_num_d:5, hll_date:5" +
|
||||
", med:2.0, perc:[-9.0,2.0,11.0] }"
|
||||
|
|
Loading…
Reference in New Issue