K - the type of the document id in the search resultspublic class SearchReplyParser<K> extends Object implements ComplexDataParser<SearchReply<K>>
SearchReply
objects. This parser handles both RESP2 and RESP3 protocol responses and supports various search result formats including
results with scores, content, IDs, and cursor-based pagination.
The parser automatically detects the Redis protocol version and switches between RESP2 and RESP3 parsing strategies. It supports the following search result features:
Document ids are decoded through the connection's key codec; rows that carry no id (FT.AGGREGATE and FT.CURSOR READ) get a
null id. Field names are schema identifiers (hash field names, JSONPath expressions or aliases) and are decoded as
raw UTF-8; field values are kept as raw bytes so that binary content (for example vector embeddings) survives the round-trip.
Nested field values produced by aggregation reducers (for example REDUCE COLLECT) are converted recursively into
FieldValue arrays and maps. Sort keys are decoded as UTF-8 text exactly as serialized by the server (see
SearchReply.SearchResult.getSortKey()).
| Constructor and Description |
|---|
SearchReplyParser(RedisCodec<K,?> codec)
Creates a new SearchReplyParser with default parsing configuration.
|
SearchReplyParser(RedisCodec<K,?> codec,
SearchArgs<K> args)
Creates a new SearchReplyParser configured based on the provided search arguments.
|
| Modifier and Type | Method and Description |
|---|---|
SearchReply<K> |
parse(ComplexData data)
Parses Redis Search command response data into a structured
SearchReply object. |
public SearchReplyParser(RedisCodec<K,?> codec, SearchArgs<K> args)
SearchReply.codec - the Redis codec used for decoding document ids. Must not be null.args - the search arguments that determine parsing behavior. If null, default parsing behavior is used (with
content, without scores, with IDs).
args.isWithScores() is true, search scores will be parsed and includedargs.isWithSortKeys() is true, sort keys will be parsed and includedargs.isNoContent() is true, document content will be excluded from parsingpublic SearchReplyParser(RedisCodec<K,?> codec)
Default configuration:
withScores = false)withSortKeys = false)withContent = true)withIds = false); every parsed row has a null idcodec - the Redis codec used for decoding document ids. Must not be null.public SearchReply<K> parse(ComplexData data)
SearchReply object. This method automatically detects
the Redis protocol version (RESP2 or RESP3) and uses the appropriate parsing strategy.parse in interface ComplexDataParser<SearchReply<K>>data - the complex data structure returned by Redis containing the search results. Must not be null.SearchReply containing the parsed search results. Never null. Returns an empty
SearchReply if parsing fails.Copyright © 2026 lettuce.io. All rights reserved.