MCPcopy
hub / github.com/redis/redis-py / _parse_hybrid_search_resp3

Method _parse_hybrid_search_resp3

redis/commands/search/commands.py:531–558  ·  view source on GitHub ↗

Parse RESP3 FT.HYBRID response into HybridResult/HybridCursorResult. Top-level keys are normalised to strings. Values are preserved as delivered by the wire (bytes when ``NEVER_DECODE`` is set, strings otherwise) so byte/str semantics match the RESP2 legacy parser.

(self, res, **kwargs)

Source from the content-addressed store, hash-verified

529 # ---- RESP3 HYBRID parsers ----
530
531 def _parse_hybrid_search_resp3(self, res, **kwargs):
532 """Parse RESP3 FT.HYBRID response into HybridResult/HybridCursorResult.
533
534 Top-level keys are normalised to strings. Values are preserved
535 as delivered by the wire (bytes when ``NEVER_DECODE`` is set,
536 strings otherwise) so byte/str semantics match the RESP2 legacy
537 parser.
538 """
539 res = {str_if_bytes(k): v for k, v in res.items()}
540 if "cursor" in kwargs:
541 return HybridCursorResult(
542 search_cursor_id=int(res["SEARCH"]),
543 vsim_cursor_id=int(res["VSIM"]),
544 )
545
546 results: List[Dict[str, Any]] = []
547 for res_item in res.get("results", []):
548 if isinstance(res_item, dict):
549 results.append({str_if_bytes(k): v for k, v in res_item.items()})
550 else:
551 results.append(pairs_to_dict(res_item, decode_keys=True))
552
553 return HybridResult(
554 total_results=int(res.get("total_results", 0)),
555 results=results,
556 warnings=res.get("warnings", []),
557 execution_time=float(res.get("execution_time", 0)),
558 )
559
560 def _parse_hybrid_search_resp3_unified(self, res, **kwargs):
561 """Parse RESP3 FT.HYBRID into the approved unified HybridResult."""

Callers

nothing calls this directly

Calls 6

str_if_bytesFunction · 0.90
HybridCursorResultClass · 0.90
pairs_to_dictFunction · 0.90
HybridResultClass · 0.90
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected