Class SearchHit<T>

java.lang.Object
org.springframework.data.elasticsearch.core.SearchHit<T>
Type Parameters:
T - the result data class.

public class SearchHit<T> extends Object
Encapsulates the found data with additional information from the search.
Since:
4.0
Author:
Peter-Josef Meisch, Matt Gilene
  • Constructor Details

  • Method Details

    • getIndex

      @Nullable public String getIndex()
      Returns:
      the index name where the hit's document was found
      Since:
      4.1
    • getId

      @Nullable public String getId()
    • getScore

      public float getScore()
      Returns:
      the score for the hit.
    • getContent

      public T getContent()
      Returns:
      the object data from the search.
    • getSortValues

      public List<Object> getSortValues()
      Returns:
      the sort values if the query had a sort criterion.
    • getHighlightFields

      public Map<String,List<String>> getHighlightFields()
      Returns:
      the map from field names to highlight values, never null
    • getHighlightField

      public List<String> getHighlightField(String field)
      gets the highlight values for a field.
      Parameters:
      field - must not be null
      Returns:
      possibly empty List, never null
    • getInnerHits

      @Nullable public SearchHits<?> getInnerHits(String name)
      returns the SearchHits for the inner hits with the given name. If the inner hits could be mapped to a nested entity class, the returned data will be of this type, otherwise {SearchDocument} instances are returned in this SearchHits object.
      Parameters:
      name - the inner hits name
      Returns:
      SearchHits if available, otherwise null
    • getInnerHits

      public Map<String,SearchHits<?>> getInnerHits()
      Returns:
      the map from inner_hits names to inner hits, in a SearchHits object, never null
      Since:
      4.1
    • getNestedMetaData

      @Nullable public NestedMetaData getNestedMetaData()
      If this is a nested inner hit, return the nested metadata information
      Returns:
      {NestedMetaData
      Since:
      4.1
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getRouting

      @Nullable public String getRouting()
      Returns:
      the routing for this SearchHit, may be null.
      Since:
      4.2
    • getExplanation

      @Nullable public Explanation getExplanation()
      Returns:
      the explanation for this SearchHit.
      Since:
      4.2
    • getMatchedQueries

      @Nullable public List<String> getMatchedQueries()
      Returns:
      the matched queries for this SearchHit.