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 newSearchResult
with the given content and a raw score value.SearchResult
(T content, Score score) Creates a newSearchResult
with the given content andScore
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the content associated with this result.getScore()
Returns theScore
associated with this result.int
hashCode()
<U> SearchResult<U>
Creates a newSearchResult
by applying the given mappingFunction
to this result's content.toString()
-
Constructor Details
-
SearchResult
Creates a newSearchResult
with the given content andScore
.- Parameters:
content
- the result content, must not be null.score
- the result score, must not be null.
-
SearchResult
Create a newSearchResult
with 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 theScore
associated with this result. -
map
Creates a newSearchResult
by applying the given mappingFunction
to 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
SearchResult
instance with converted content.
-
equals
-
hashCode
public int hashCode() -
toString
-