You can retrieve specific items from the index by their IDs using the get() method:
Copy
Ask AI
# IDs of items to retrieveids = ["item_20", "item_11"]include = ["contents", "metadata"]# Retrieve items from the encrypted indexitems = index.get(ids, include)print(items)# Example items (contents returned in their original format - string or bytes)# [{"id": "item_20", "contents": "Hello, World!", "metadata": {"type": "txt"}},# {"id": "item_11", "contents": "Hello, Cyborg!", "metadata": {"type": "md"}}]
You can specify which fields to include in the response:
vector: The vector data itself
contents: Content associated with the vector (returned in original format)
metadata: Structured metadata object
In Python, the contents field is returned in its original format (string or bytes) as it was stored. String contents remain strings, and bytes contents remain bytes after decryption. In JavaScript/TypeScript, contents are returned as decoded UTF-8 strings. In Go, contents are returned as string.
If you don’t specify include, the default is ["vector", "contents", "metadata"]. Note: id is always included in results.
For IVFPQ and IVFSQ index types, the vector field cannot be included in the response as these index types use compression techniques that don’t preserve original vectors.