如何根据 ChromaDB 中的元数据在两个值之间进行过滤?

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

我想通过根据我存储在元数据中的日期进行过滤来限制 chromaDB 查询期间的搜索。我只想搜索两个日期之间的文档。我尝试了以下条件 -


results = collection.query( 
                    query_embeddings=query_embedding,
                    n_results=5, 
                    where={"timestamp": 
                           {"$lte":datetime.strptime('2024-01-10',"%Y-%m-%d").timestamp(),
                            "$gte":datetime.strptime('2024-01-01',"%Y-%m-%d").timestamp()}},
                )

但是我收到了这个错误- enter image description here

有人可以告诉我哪里出错了吗?

chromadb
1个回答
0
投票

弄清楚了如何构造 where 子句 -

where = {'$and':[{'timestamp':{"$gte":start_timestamp}}, {'timestamp':{"$lte":end_timestamp}}]}

这有效。

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