Class ValuesSource

java.lang.Object
org.elasticsearch.search.aggregations.support.ValuesSource
Direct Known Subclasses:
ValuesSource.Bytes, ValuesSource.GeoPoint, ValuesSource.Numeric, ValuesSource.Range

public abstract class ValuesSource
extends java.lang.Object
A unified interface to different ways of getting input data for Aggregators like DocValues from Lucene or script output. The top level sub-classes define type-specific behavior, such as ValuesSource.Numeric.isFloatingPoint(). Second level subclasses are then specialized based on where they read values from, e.g. script or field cases. There are also adapter classes like CellIdSource which do run-time conversion from one type to another, often dependent on a user specified parameter (precision in that case).
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  ValuesSource.Bytes
    ValuesSource for fields who's values are best thought of as byte arrays without any other meaning like keyword or ip.
    static class  ValuesSource.GeoPoint
    ValuesSource for fields who's values are best thought of as points on a globe.
    static class  ValuesSource.Numeric
    ValuesSource for fields who's values are best thought of as numbers.
    static class  ValuesSource.Range
    ValuesSource for fields who's values are best thought of as ranges of numbers, dates, or IP addresses.
  • Constructor Summary

    Constructors
    Constructor Description
    ValuesSource()  
  • Method Summary

    Modifier and Type Method Description
    abstract SortedBinaryDocValues bytesValues​(org.apache.lucene.index.LeafReaderContext context)
    Get a byte array like view into the values.
    abstract DocValueBits docsWithValue​(org.apache.lucene.index.LeafReaderContext context)
    Get a "has any values" view into the values.
    boolean hasOrdinals()
    Check if this values source supports using global and segment ordinals.
    boolean needsScores()
    Whether this values source needs scores.
    protected abstract java.util.function.Function<Rounding,​Rounding.Prepared> roundingPreparer()
    Build a function to prepare Roundings.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ValuesSource

      public ValuesSource()
  • Method Details

    • bytesValues

      public abstract SortedBinaryDocValues bytesValues​(org.apache.lucene.index.LeafReaderContext context) throws java.io.IOException
      Get a byte array like view into the values. This is the "native" way to access ValuesSource.Bytes-style values.
      Throws:
      java.io.IOException
    • docsWithValue

      public abstract DocValueBits docsWithValue​(org.apache.lucene.index.LeafReaderContext context) throws java.io.IOException
      Get a "has any values" view into the values. It'll try to pick the "most native" way to check if there are any values, but it builds its own view into the values so if you need any of the actual values its best to use something like bytesValues(org.apache.lucene.index.LeafReaderContext) or ValuesSource.Numeric.doubleValues(org.apache.lucene.index.LeafReaderContext) but if you just need to know if there are any values then use this.
      Throws:
      java.io.IOException
    • needsScores

      public boolean needsScores()
      Whether this values source needs scores.
    • roundingPreparer

      protected abstract java.util.function.Function<Rounding,​Rounding.Prepared> roundingPreparer() throws java.io.IOException
      Build a function to prepare Roundings.

      This returns a Function because auto date histogram will need to call it many times over the course of running the aggregation. Other aggregations should feel free to call it once.

      Throws:
      java.io.IOException
    • hasOrdinals

      public boolean hasOrdinals()
      Check if this values source supports using global and segment ordinals.

      If this returns true then it is safe to cast it to ValuesSource.Bytes.WithOrdinals.