@Override public void collect(int doc, long bucket) throws IOException { if (values.advanceExact(doc)) { final int valuesCount = values.docValueCount(); for (int i = 0, lo = 0; i < valuesCount; ++i) { final double value = values.nextValue(); lo = collect(doc, value, bucket, lo); } } }
@Override protected double pick(SortedNumericDoubleValues values) throws IOException { final int count = values.docValueCount(); double total = 0; for (int index = 0; index < count; ++index) { total += values.nextValue(); } return total / count; }
@Override public boolean advanceExact(int doc) throws IOException { if (values.advanceExact(doc)) { count = values.docValueCount(); } else { count = 0; } // always return true because we want to return a value even if // the document does not have a value return true; }
@Override protected double pick(SortedNumericDoubleValues values, double missingValue, int doc) { values.setDocument(doc); int count = values.count(); return count > 0 ? values.valueAt(0) : missingValue; }
@Override public boolean advanceExact(int target) throws IOException { return values.advanceExact(target); } };
@Override public void setDocument(int doc) { values.setDocument(doc); count = values.count(); }
@Override protected double pick(SortedNumericDoubleValues values, double missingValue, DocIdSetIterator docItr, int startDoc, int endDoc, int maxChildren) throws IOException { boolean hasValue = false; double minValue = Double.POSITIVE_INFINITY; int count = 0; for (int doc = startDoc; doc < endDoc; doc = docItr.nextDoc()) { if (values.advanceExact(doc)) { if (++count > maxChildren) { break; } minValue = Math.min(minValue, values.nextValue()); hasValue = true; } } return hasValue ? minValue : missingValue; }
@Override public long valueAt(int index) { return (long) values.valueAt(index); }
@Override public int docValueCount() { return values.docValueCount(); }
@Override public int count() { return values.count(); }
@Override public void setDocument(int docId) { values.setDocument(docId); }
@Override public double nextValue() throws IOException { if (count > 0) { return values.nextValue(); } else { return missing; } }
@Override protected double pick(SortedNumericDoubleValues values, double missingValue, int doc) { values.setDocument(doc); final int count = values.count(); return count > 0 ? values.valueAt(count - 1) : missingValue; }
@Override protected double pick(SortedNumericDoubleValues values) throws IOException { final int count = values.docValueCount(); for (int i = 0; i < count - 1; ++i) { values.nextValue(); } return values.nextValue(); }
@Override public boolean advanceExact(int doc) throws IOException { return doubleValues.advanceExact(doc); } };
@Override public boolean get(int index) { dv.setDocument(index); return dv.count() != 0; }
@Override public double score(int docId, float subQueryScore) throws IOException { double value; if (values.advanceExact(docId)) { value = values.nextValue(); } else { if (missing != null) { value = missing; } else { throw new ElasticsearchException("Missing value for field [" + field + "]"); } } double val = value * boostFactor; double result = modifier.apply(val); if (result < 0f) { deprecationLogger.deprecatedAndMaybeLog( "negative score in function score query", "Negative scores for field value function are deprecated," + " and will throw an error in the next major version. Got: [" + result + "] for field value: [" + value + "]" ); } return result; }
@Override public Double get(int index) { return values.valueAt(index); }
@Override public int count() { return values.docValueCount(); }