Class DoubleValuesSource

    • Constructor Detail

      • DoubleValuesSource

        public DoubleValuesSource()
    • Method Detail

      • needsScores

        public abstract boolean needsScores()
        Return true if document scores are needed to calculate values
      • rewrite

        public abstract DoubleValuesSource rewrite​(IndexSearcher reader)
                                            throws IOException
        Return a DoubleValuesSource specialised for the given IndexSearcher

        Implementations should assume that this will only be called once. IndexReader-independent implementations can just return this

        Queries that use DoubleValuesSource objects should call rewrite() during Query.createWeight(IndexSearcher, ScoreMode, float) rather than during Query.rewrite(IndexReader) to avoid IndexReader reference leakage.

        For the same reason, implementations that cache references to the IndexSearcher should return a new object from this method.

        Throws:
        IOException
      • getSortField

        public SortField getSortField​(boolean reverse)
        Create a sort field based on the value of this producer
        Parameters:
        reverse - true if the sort should be decreasing
      • hashCode

        public abstract int hashCode()
        Overrides:
        hashCode in class Object
      • equals

        public abstract boolean equals​(Object obj)
        Overrides:
        equals in class Object
      • toLongValuesSource

        public final LongValuesSource toLongValuesSource()
        Convert to a LongValuesSource by casting the double values to longs
      • fromField

        public static DoubleValuesSource fromField​(String field,
                                                   LongToDoubleFunction decoder)
        Creates a DoubleValuesSource that wraps a generic NumericDocValues field
        Parameters:
        field - the field to wrap, must have NumericDocValues
        decoder - a function to convert the long-valued doc values to doubles
      • fromDoubleField

        public static DoubleValuesSource fromDoubleField​(String field)
        Creates a DoubleValuesSource that wraps a double-valued field
      • fromFloatField

        public static DoubleValuesSource fromFloatField​(String field)
        Creates a DoubleValuesSource that wraps a float-valued field
      • fromLongField

        public static DoubleValuesSource fromLongField​(String field)
        Creates a DoubleValuesSource that wraps a long-valued field
      • fromIntField

        public static DoubleValuesSource fromIntField​(String field)
        Creates a DoubleValuesSource that wraps an int-valued field
      • constant

        public static DoubleValuesSource constant​(double value)
        Creates a DoubleValuesSource that always returns a constant value
      • fromQuery

        public static DoubleValuesSource fromQuery​(Query query)
        Create a DoubleValuesSource that returns the score of a particular query