ChromaDB 获取唯一元数据字段列表

问题描述 投票:0回答:1

我正在使用 ChromaDB 集合,需要有效地提取特定元数据字段的所有唯一值的列表。


collection = client.get_collection(collection_name)
unique_keys = collection.get(where={"$distinct": "metadata_key"}) #not working as expected

#in db `metadata_key` is like `sentiment` that can have value like good, bad, etc

目前我使用这种低效的方式

all_metadatas  = collection.get(include=["metadatas"]).get('metadatas')
distinct_keys = set([x.get('metadata_key') for x  in all_metadatas])
python chromadb
1个回答
0
投票

提出了用例的增强请求

https://github.com/chroma-core/chroma/issues/2873

© www.soinside.com 2019 - 2024. All rights reserved.