在 ChromaDB 中,如何拥有与每个文档关联的元数据字典列表并查询它们?

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

我有以下内容:

collection.add(
    documents=["doc1", "doc2"],
    metadatas=[{'data': '{"entity_text": "Patient", "entity_group": "species", "normalized_id": "[\'NCBITaxon:9606\']", "field": "Exclusion Criteria", "is_negated": "no"}, {"entity_text": "donor", "entity_group": "Subject", "normalized_id": "CUI-less", "field": "Exclusion Criteria", "is_negated": "no"}, {"entity_text": "pregnant lactating", "entity_group": "pregnancy", "normalized_id": "CUI-less", "field": "Exclusion Criteria", "is_negated": "no"}'}, {'data': '{"entity_text": "bilirubin", "entity_group": "drug", "normalized_id": "[\'mesh:D001663\']", "field": "Exclusion Criteria", "is_negated": "no"}, {"entity_text": "serum", "entity_group": "Biological_structure", "normalized_id": "CUI-less", "field": "Exclusion Criteria", "is_negated": "no"}, {"entity_text": "greater than 4 mg / dl", "entity_group": "Lab_value", "normalized_id": "CUI-less", "field": "Exclusion Criteria", "is_negated": "no"}, {"entity_text": "transaminases", "entity_group": "Diagnostic_procedure", "normalized_id": "CUI-less", "field": "Exclusion Criteria", "is_negated": "no"}, {"entity_text": "greater than 5", "entity_group": "Lab_value", "normalized_id": "CUI-less", "field": "Exclusion Criteria", "is_negated": "no"}'}],

 ids=["id1", "id2"]
)

这里

metadatas
实际上是两个字典的字典列表。您知道是否可以查询这样的结构吗?如果是的话,怎么办?

我不知道如何为此编写查询。

database vector chromadb
1个回答
0
投票

我无法明确回答您的问题,但我一直在寻找有关执行类似操作(存储具有多个值的元数据字段)的信息,但我没有在任何地方看到任何人提到这样做。我在 ChromaDB 文档中没有发现有关将任何值传递到除简单字符串之外的元数据字段的信息。我想说的是,除非您尝试了上面的 .add() 语句并且它被接受而没有抛出异常,否则我们可能会假设不支持简单字符串以外的任何内容。我将尝试将关键字直接嵌入到文本中并使用 $in 对其进行查询。也许这个概念在你的情况下值得考虑?

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