Class SearchHit<T>
java.lang.Object
org.springframework.data.elasticsearch.core.SearchHit<T>
- Type Parameters:
T
- the result data class.
Encapsulates the found data with additional information from the search.
- Since:
- 4.0
- Author:
- Peter-Josef Meisch, Matt Gilene
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetHighlightField
(String field) gets the highlight values for a field.getId()
getIndex()
Map<String,
SearchHits<?>> SearchHits<?>
getInnerHits
(String name) returns theSearchHits
for the inner hits with the given name.If this is a nested inner hit, return the nested metadata informationfloat
getScore()
toString()
-
Constructor Details
-
SearchHit
public SearchHit(@Nullable String index, @Nullable String id, @Nullable String routing, float score, @Nullable Object[] sortValues, @Nullable Map<String, List<String>> highlightFields, @Nullable Map<String, SearchHits<?>> innerHits, @Nullable NestedMetaData nestedMetaData, @Nullable Explanation explanation, @Nullable List<String> matchedQueries, T content)
-
-
Method Details
-
getIndex
- Returns:
- the index name where the hit's document was found
- Since:
- 4.1
-
getId
-
getScore
public float getScore()- Returns:
- the score for the hit.
-
getContent
- Returns:
- the object data from the search.
-
getSortValues
- Returns:
- the sort values if the query had a sort criterion.
-
getHighlightFields
- Returns:
- the map from field names to highlight values, never null
-
getHighlightField
gets the highlight values for a field.- Parameters:
field
- must not be null- Returns:
- possibly empty List, never null
-
getInnerHits
returns theSearchHits
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 thisSearchHits
object.- Parameters:
name
- the inner hits name- Returns:
SearchHits
if available, otherwise null
-
getInnerHits
- Returns:
- the map from inner_hits names to inner hits, in a
SearchHits
object, never null - Since:
- 4.1
-
getNestedMetaData
If this is a nested inner hit, return the nested metadata information- Returns:
- {
NestedMetaData
- Since:
- 4.1
-
toString
-
getRouting
- Returns:
- the routing for this SearchHit, may be null.
- Since:
- 4.2
-
getExplanation
- Returns:
- the explanation for this SearchHit.
- Since:
- 4.2
-
getMatchedQueries
- Returns:
- the matched queries for this SearchHit.
-