Record Class SearchResult<T>

java.lang.Object
java.lang.Record
io.micronaut.data.model.vector.search.SearchResult<T>
Type Parameters:
T - The entity type
Record Components:
entity - The matched entity
score - The computed score
similarity - The normalized similarity derived from score when scoring function is known

public record SearchResult<T>(@NonNull T entity, @NonNull Score score, @Nullable Similarity similarity) extends Record
Single vector search result containing entity, score and optional normalized similarity.
Since:
5.0.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    SearchResult(@NonNull T entity, @NonNull Score score)
    Creates a search result without normalized similarity.
    SearchResult(@NonNull T entity, @NonNull Score score, @Nullable Similarity similarity)
    Creates an instance of a SearchResult record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NonNull T
    Returns the value of the entity record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    @NonNull Score
    Returns the value of the score record component.
    @Nullable Similarity
    Returns the value of the similarity record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SearchResult

      public SearchResult(@NonNull T entity, @NonNull Score score)
      Creates a search result without normalized similarity.
      Parameters:
      entity - matched entity
      score - computed score
    • SearchResult

      public SearchResult(@NonNull T entity, @NonNull Score score, @Nullable Similarity similarity)
      Creates an instance of a SearchResult record class.
      Parameters:
      entity - the value for the entity record component
      score - the value for the score record component
      similarity - the value for the similarity record component
  • Method Details

    • toString

      public final 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • entity

      public @NonNull T entity()
      Returns the value of the entity record component.
      Returns:
      the value of the entity record component
    • score

      public @NonNull Score score()
      Returns the value of the score record component.
      Returns:
      the value of the score record component
    • similarity

      public @Nullable Similarity similarity()
      Returns the value of the similarity record component.
      Returns:
      the value of the similarity record component