开始使用免费开始使用

多重元数据筛选

除等值判断外,Pinecone 还提供其他核心比较运算符,并支持在一次查询中使用多个筛选条件。本练习中,您将使用 Pinecone 的其他比较运算符创建多个筛选条件,并用它们重新查询索引。

本练习是课程的一部分

使用 Pinecone 构建 AI 应用

查看课程

练习说明

  • 使用您的 API 密钥初始化 Pinecone 连接。
  • 仅在 "genre" 元数据为 "thriller""year" 小于 2018 的向量中检索与给定 vector相似向量。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Initialize the Pinecone client using your API key
pc = Pinecone(api_key="____")

index = pc.Index('datacamp-index')

# Retrieve the MOST similar vector with genre and year filters
query_result = index.query(
    vector=vector,
    top_k=1,
    filter=____
)
print(query_result)
编辑并运行代码