Record Class RankedDocsResults.RankedDoc

java.lang.Object
java.lang.Record
org.elasticsearch.xpack.core.inference.results.RankedDocsResults.RankedDoc
Record Components:
index - the index of the document when it was passed to the cohere rerank API
relevanceScore -
text -
All Implemented Interfaces:
Comparable<RankedDocsResults.RankedDoc>, Writeable, org.elasticsearch.xcontent.ToXContent, org.elasticsearch.xcontent.ToXContentObject
Enclosing class:
RankedDocsResults

public static record RankedDocsResults.RankedDoc(int index, float relevanceScore, String text) extends Record implements Comparable<RankedDocsResults.RankedDoc>, Writeable, org.elasticsearch.xcontent.ToXContentObject
A record representing a document that has been ranked by the cohere rerank API
  • Field Details

    • NAME

      public static final String NAME
      See Also:
    • INDEX

      public static final String INDEX
      See Also:
    • RELEVANCE_SCORE

      public static final String RELEVANCE_SCORE
      See Also:
    • TEXT

      public static final String TEXT
      See Also:
    • INDEX_FIELD

      public static final org.elasticsearch.xcontent.ParseField INDEX_FIELD
    • RELEVANCE_SCORE_FIELD

      public static final org.elasticsearch.xcontent.ParseField RELEVANCE_SCORE_FIELD
    • TEXT_FIELD

      public static final org.elasticsearch.xcontent.ParseField TEXT_FIELD
  • Constructor Details

    • RankedDoc

      public RankedDoc(int index, float relevanceScore, @Nullable String text)
      Creates an instance of a RankedDoc record class.
      Parameters:
      index - the value for the index record component
      relevanceScore - the value for the relevanceScore record component
      text - the value for the text record component
  • Method Details

    • createParser

      public static org.elasticsearch.xcontent.ConstructingObjectParser<RankedDocsResults.RankedDoc,Void> createParser(boolean ignoreUnknownFields)
    • toXContent

      public org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.xcontent.ToXContent
      Throws:
      IOException
    • of

      public static RankedDocsResults.RankedDoc of(StreamInput in) throws IOException
      Throws:
      IOException
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • asMap

      public Map<String,Object> asMap()
    • compareTo

      public int compareTo(RankedDocsResults.RankedDoc other)
      Specified by:
      compareTo in interface Comparable<RankedDocsResults.RankedDoc>
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • index

      public int index()
      Returns the value of the index record component.
      Returns:
      the value of the index record component
    • relevanceScore

      public float relevanceScore()
      Returns the value of the relevanceScore record component.
      Returns:
      the value of the relevanceScore record component
    • text

      @Nullable public String text()
      Returns the value of the text record component.
      Returns:
      the value of the text record component