org.apache.lucene.queries.function

## Class ValueSource

- java.lang.Object
- - org.apache.lucene.queries.function.ValueSource

- Direct Known Subclasses:
    BoolFunction, ConstNumberSource, DocFreqValueSource, DualFloatFunction, FieldCacheSource, LinearFloatFunction, LiteralValueSource, MaxDocValueSource, MultiFloatFunction, MultiFunction, MultiValueSource, NormValueSource, NumDocsValueSource, QueryValueSource, RangeMapFloatFunction, ReciprocalFloatFunction, ScaleFloatFunction, SingleFunction, SumTotalTermFreqValueSource, TotalTermFreqValueSource

      public abstract class ValueSource
      extends Object

  Instantiates `FunctionValues` for a particular reader.
  Often used when creating a `FunctionQuery`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ValueSource()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DoubleValuesSource` | `asDoubleValuesSource()` Expose this ValueSource as a DoubleValuesSource
    `LongValuesSource` | `asLongValuesSource()` Expose this ValueSource as a LongValuesSource
    `void` | `createWeight(Map context, IndexSearcher searcher)` Implementations should propagate createWeight to sub-ValueSources which can optionally store weight info in the context.
    `abstract String` | `description()` description of field, used in explain()
    `abstract boolean` | `equals(Object o)`
    `static ValueSource` | `fromDoubleValuesSource(DoubleValuesSource in)`
    `SortField` | `getSortField(boolean reverse)` EXPERIMENTAL: This method is subject to change.
    `abstract FunctionValues` | `getValues(Map context, LeafReaderContext readerContext)` Gets the values for this reader and the context that was previously passed to createWeight().
    `abstract int` | `hashCode()`
    `static Map` | `newContext(IndexSearcher searcher)` Returns a new non-threadsafe context map.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ValueSource

          public ValueSource()

  - ### Method Detail

    - #### getValues

          public abstract FunctionValues getValues(Map context,
                                                   LeafReaderContext readerContext)
                                            throws IOException

      Gets the values for this reader and the context that was previously passed to createWeight(). The values must be consumed in a forward docID manner, and you must call this method again to iterate through the values again.
      Throws:
        `IOException`

    - #### equals

          public abstract boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public abstract int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### description

          public abstract String description()

      description of field, used in explain()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### createWeight

          public void createWeight(Map context,
                                   IndexSearcher searcher)
                            throws IOException

      Implementations should propagate createWeight to sub-ValueSources which can optionally store weight info in the context. The context object will be passed to getValues() where this info can be retrieved.
      Throws:
        `IOException`

    - #### newContext

          public static Map newContext(IndexSearcher searcher)

      Returns a new non-threadsafe context map.

    - #### asLongValuesSource

          public LongValuesSource asLongValuesSource()

      Expose this ValueSource as a LongValuesSource

    - #### asDoubleValuesSource

          public DoubleValuesSource asDoubleValuesSource()

      Expose this ValueSource as a DoubleValuesSource

    - #### fromDoubleValuesSource

          public static ValueSource fromDoubleValuesSource(DoubleValuesSource in)

    - #### getSortField

          public SortField getSortField(boolean reverse)

      EXPERIMENTAL: This method is subject to change.

      Get the SortField for this ValueSource. Uses the `getValues(java.util.Map, org.apache.lucene.index.LeafReaderContext)` to populate the SortField.

      Parameters:
        `reverse` - true if this is a reverse sort.
      Returns:
        The `SortField` for the ValueSource

Copyright © 2000-2024 Apache Software Foundation. All Rights Reserved.