I have to check in my code if a collection have some data. I have created a function where it loads all the data from collection, but this will take time everytime, is there any other way to do it quickly without loading all the data from collection.
Below is my sample function to load all data, Thanks!
def load_all_data_from_class_with_embeddings(class_name):
Get the collection
collection = client.collections.get(class_name)
# Fetch all objects using iterator
all_results = []
for item in collection.iterator():
result = {'skill_name': item.properties.get('skill_name')}
all_results.append(result)
# Convert the list of results into a DataFrame
df = pd.DataFrame(all_results)
return df (edited)