org.apache.lucene.search

## Class SimpleFieldComparator<T>

- java.lang.Object
- - org.apache.lucene.search.FieldComparator<T>
  - - org.apache.lucene.search.SimpleFieldComparator<T>

- All Implemented Interfaces:
    LeafFieldComparator
  Direct Known Subclasses:
    FieldComparator.NumericComparator

      public abstract class SimpleFieldComparator<T>
      extends FieldComparator<T>
      implements LeafFieldComparator

  Base `FieldComparator` implementation that is used for all contexts.
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.lucene.search.FieldComparator

      `FieldComparator.DocComparator, FieldComparator.DoubleComparator, FieldComparator.FloatComparator, FieldComparator.IntComparator, FieldComparator.LongComparator, FieldComparator.NumericComparator<T extends Number>, FieldComparator.RelevanceComparator, FieldComparator.TermOrdValComparator, FieldComparator.TermValComparator`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleFieldComparator()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `doSetNextReader(LeafReaderContext context)` This method is called before collecting `context`.
    `LeafFieldComparator` | `getLeafComparator(LeafReaderContext context)` Get a per-segment `LeafFieldComparator` to collect the given `LeafReaderContext`.
    `void` | `setScorer(Scorable scorer)` Sets the Scorer to use in case a document's score is needed.

    - ### Methods inherited from class org.apache.lucene.search.FieldComparator

      `compare, compareValues, setTopValue, value`

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.lucene.search.LeafFieldComparator

      `compareBottom, compareTop, copy, setBottom`

- - ### Constructor Detail

    - #### SimpleFieldComparator

          public SimpleFieldComparator()

  - ### Method Detail

    - #### doSetNextReader

          protected abstract void doSetNextReader(LeafReaderContext context)
                                           throws IOException

      This method is called before collecting `context`.
      Throws:
        `IOException`

    - #### getLeafComparator

          public final LeafFieldComparator getLeafComparator(LeafReaderContext context)
                                                      throws IOException

      Description copied from class: `FieldComparator`
      Get a per-segment `LeafFieldComparator` to collect the given `LeafReaderContext`. All docIDs supplied to this `LeafFieldComparator` are relative to the current reader (you must add docBase if you need to map it to a top-level docID).
      Specified by:
        `getLeafComparator` in class `FieldComparator<T>`
      Parameters:
        `context` - current reader context
      Returns:
        the comparator to use for this segment
      Throws:
        `IOException` - if there is a low-level IO error

    - #### setScorer

          public void setScorer(Scorable scorer)
                         throws IOException

      Description copied from interface: `LeafFieldComparator`
      Sets the Scorer to use in case a document's score is needed.
      Specified by:
        `setScorer` in interface `LeafFieldComparator`
      Parameters:
        `scorer` - Scorer instance that you should use to obtain the current hit's score, if necessary.
      Throws:
        `IOException`

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