K - Key type of the document id.public static class SearchReply.SearchResult<K> extends Object
getFields() maps each field name to a FieldValue, which retains the exact bytes returned by the server
and can be read as either text (FieldValue.asString()) or binary (FieldValue.asBytes()). This lets a
single document mix textual/numeric fields with binary fields such as vector embeddings, where UTF-8 decoding would
corrupt the value.
| Constructor and Description |
|---|
SearchResult()
Creates a new SearchResult without a document ID, for rows that carry none (aggregation results).
|
SearchResult(K id)
Creates a new SearchResult with the specified document ID.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addField(String key,
byte[] value)
Adds a single document field
|
void |
addFields(Map<String,byte[]> fields)
Adds all the provided fields
|
Map<String,FieldValue> |
getFields()
Gets the document fields, mapping each field name to its
FieldValue, in the order returned by the server. |
K |
getId()
Gets the document ID.
|
Double |
getScore()
Gets the document score.
|
String |
getSortKey()
Gets the sort key of the document, as serialized by the server.
|
public SearchResult(K id)
id - the document IDpublic SearchResult()
public K getId()
Rows of FT.AGGREGATE and FT.CURSOR READ replies carry no document ID, so this is null for
every result of an AggregationReply. Load the key explicitly (LOAD 1 __key) if it is needed there.
null if the reply carries no document IDs (aggregation results)public Double getScore()
This is only available if WITHSCORES was used in the search.
public String getSortKey()
This is only available if WITHSORTKEYS was used together with SORTBY. The server prefixes a textual sort key with
$ (normalized to lower case unless the attribute was declared UNF, for example $hello world)
and a numeric sort key with # (for example #10), so the type of the sorting attribute can be told
apart. It is mostly useful for merging sorted results coming from several indexes or shards.
null if WITHSORTKEYS was not used, no SORTBY was given, or the document has no value
for the sorting attributepublic Map<String,FieldValue> getFields()
FieldValue, in the order returned by the server. If
NOCONTENT was used in the search, this will be empty. Read each value as text via FieldValue.asString() or as
raw bytes via FieldValue.asBytes().
Aggregation reducers that produce non-scalar columns (for example FT.AGGREGATE REDUCE COLLECT) are
represented as FieldValue.Kind.ARRAY values with one element per collected entry; read the entries via
FieldValue.asList() and each entry via FieldValue.asMap(), which normalizes the protocol-specific
entry shape. Entry order within a collected column follows the server (SORTBY order); iteration order of
FieldValue.Kind.MAP values is not guaranteed to match the server.
FieldValue, or an empty map if not availablepublic void addFields(Map<String,byte[]> fields)
fields - the document fields, keyed by name, with raw byte valuespublic void addField(String key, byte[] value)
key - the field namevalue - the raw field valueCopyright © 2026 lettuce.io. All rights reserved.