Class DoubleValuesSource

    • Constructor Detail

      • DoubleValuesSource

        public DoubleValuesSource()
    • Method Detail

      • needsScores

        public abstract boolean needsScores()
        Return true if document scores are needed to calculate values
      • 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
      • similarityToQueryVector

        public static DoubleValues similarityToQueryVector​(LeafReaderContext ctx,
                                                           byte[] queryVector,
                                                           String vectorField)
                                                    throws IOException
        Returns a DoubleValues instance for computing the vector similarity score per document against the byte query vector
        Parameters:
        ctx - the context for which to return the DoubleValues
        queryVector - byte query vector
        vectorField - knn byte field name
        Returns:
        DoubleValues instance
        Throws:
        IOException - if an IOException occurs
      • similarityToQueryVector

        public static DoubleValues similarityToQueryVector​(LeafReaderContext ctx,
                                                           float[] queryVector,
                                                           String vectorField)
                                                    throws IOException
        Returns a DoubleValues instance for computing the vector similarity score per document against the float query vector
        Parameters:
        ctx - the context for which to return the DoubleValues
        queryVector - float query vector
        vectorField - knn float field name
        Returns:
        DoubleValues instance
        Throws:
        IOException - if an IOException occurs
      • 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