Package org.springframework.data.domain
Class SearchResult<T>
java.lang.Object
org.springframework.data.domain.SearchResult<T>
- Type Parameters:
T- the type of the content object
- All Implemented Interfaces:
Serializable
Immutable value object representing a search result consisting of a content item and an associated
Score.
Typically used in the context of similarity-based or vector search operations where each result carries a relevance
Score. Provides accessor methods for the content and its score, along with transformation support via
map(Function).
- Since:
- 4.0
- Author:
- Mark Paluch
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSearchResult(T content, double score) Create a newSearchResultwith the given content and a raw score value.SearchResult(T content, Score score) Creates a newSearchResultwith the given content andScore. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the content associated with this result.getScore()Returns theScoreassociated with this result.inthashCode()<U> SearchResult<U>Creates a newSearchResultby applying the given mappingFunctionto this result's content.toString()
-
Constructor Details
-
SearchResult
Creates a newSearchResultwith the given content andScore.- Parameters:
content- the result content, must not be null.score- the result score, must not be null.
-
SearchResult
Create a newSearchResultwith the given content and a raw score value.- Parameters:
content- the result content, must not be null.score- the score value.
-
-
Method Details
-
getContent
Returns the content associated with this result. -
getScore
Returns theScoreassociated with this result. -
map
Creates a newSearchResultby applying the given mappingFunctionto this result's content.- Type Parameters:
U- the target type of the mapped content.- Parameters:
converter- the mapping function to apply to the content, must not be null.- Returns:
- a new
SearchResultinstance with converted content.
-
equals
-
hashCode
public int hashCode() -
toString
-