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

Method load_document

redis/commands/search/commands.py:1176–1195  ·  view source on GitHub ↗

Load a single document by id - **field_encodings**: optional dict mapping field names to encodings. If a field's encoding is ``None`` the raw bytes value is preserved (useful for binary data such as vectors).

(self, id, field_encodings: Optional[Dict[str, Any]] = None)

Source from the content-addressed store, hash-verified

1174 return self.execute_command(*args)
1175
1176 def load_document(self, id, field_encodings: Optional[Dict[str, Any]] = None):
1177 """
1178 Load a single document by id
1179
1180 - **field_encodings**: optional dict mapping field names to encodings.
1181 If a field's encoding is ``None`` the raw bytes value is preserved
1182 (useful for binary data such as vectors).
1183 """
1184 fields = self.client.hgetall(id)
1185 fields = {
1186 str_if_bytes(k): decode_field_value(v, str_if_bytes(k), field_encodings)
1187 for k, v in fields.items()
1188 }
1189
1190 try:
1191 del fields["id"]
1192 except KeyError:
1193 pass
1194
1195 return Document(id=id, **fields)
1196
1197 @deprecated_function(version="2.0.0", reason="deprecated since redisearch 2.0")
1198 def get(self, *ids):

Callers 2

test_clientMethod · 0.45
test_clientMethod · 0.45

Calls 4

str_if_bytesFunction · 0.90
decode_field_valueFunction · 0.90
DocumentClass · 0.85
hgetallMethod · 0.80

Tested by 2

test_clientMethod · 0.36
test_clientMethod · 0.36