Get Item

Retrieves, decrypts and returns an item from its item ID. If an item does not exist at that ID, it will return an empty bytes object.

def get_item(self, id: int)

Parameters

ParameterTypeDescription
idintItem ID to retrieve & decrypt

Returns

bytes: Decrypted item bytes, or empty bytes object if no item was found at the ID provided.

Exceptions

Example Usage

# Load index
index = client.load_index(index_name=index_name, index_key=index_key)

# Retrieve the item at ID '0'
item = index.get_item(0)

print(item)
# Example output:
# b'item contents here...'

Get Items

Retrieves, decrypts and returns a list of items from their IDs. If an item does not exist at that ID, it will return an empty bytes object.

def get_items(self, ids: List[int])

Parameters

ParameterTypeDescription
idsList[int]Item IDs to retrieve & decrypt

Returns

List[bytes]: List of decrypted item bytes, or empty bytes object if no item was found at the ID provided.

Exceptions

Example Usage

# Load index
index = client.load_index(index_name=index_name, index_key=index_key)

# Perform query
query_vector = [0.1, 0.2, 0.3]
results = index.query(query_vector=query_vector, top_k=10)

# Extract the item IDs from the query
result_ids = [res["id"] for res in results]

# Retrieve the items from the query results
items = index.get_items(result_ids)

print(items)
# Example output:
# [b'item #1 contents...', b'item #2 contents...', ...]