Class SearchHit<T>
java.lang.Object
io.fluxzero.sdk.persisting.search.SearchHit<T>
- Type Parameters:
T- The type of the deserialized document value.
- All Implemented Interfaces:
Entry<T>
Represents a single result returned by a
Search query.
A SearchHit encapsulates a document retrieved from the search index, along with metadata
such as its unique ID, collection name, and optional timestamp and end time. The actual document value
is lazily supplied via a Supplier, enabling deferred deserialization or transformation.
This class implements the Entry interface and is used extensively in streaming search operations,
particularly via Search.streamHits() or Search.streamHits(int).
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SearchHit<SerializedDocument> fromDocument(SerializedDocument document) Constructs aSearchHitinstance from a rawSerializedDocument.getValue()Returns the actual value of the hit, deserialized or computed via the internalvalueSupplier.<V> SearchHit<V> Transforms the hit’s value using the provided mapper function, producing a newSearchHitwith the same metadata but with a new mapped value.
-
Constructor Details
-
SearchHit
public SearchHit()
-
-
Method Details
-
fromDocument
Constructs aSearchHitinstance from a rawSerializedDocument.This is useful when dealing with lower-level deserialization logic or constructing hits manually in test environments or in-memory stores.
- Parameters:
document- The serialized document from which to construct the search hit.- Returns:
- A new
SearchHitinstance wrapping the serialized document.
-
getValue
-
map
Transforms the hit’s value using the provided mapper function, producing a newSearchHitwith the same metadata but with a new mapped value.- Type Parameters:
V- The new value type.- Parameters:
mapper- A function to convert the current value to another type.- Returns:
- A new
SearchHitinstance with the transformed value.
-