开始使用免费开始使用

Namespaces

命名空间用于在同一个索引中隔离向量,便于定向查询,并尽量减少扫描记录的数量。

在本练习中,您将练习把向量写入 'datacamp-index' 这个 Pinecone 索引中的不同命名空间。您需要连接到该索引,把向量 upsert 到不同的命名空间,并检查索引的最新度量。

本练习是课程的一部分

使用 Pinecone 构建 AI 应用

查看课程

练习说明

  • 使用您的 API key 初始化 Pinecone 连接。
  • vector_set1 中的向量 upsert 到命名空间 namespace1
  • vector_set2 中的向量 upsert 到命名空间 namespace2
  • 打印该索引的描述性统计信息。

交互式实操练习

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

# Initialize the Pinecone client with your API key
pc = Pinecone(api_key="____")
index = pc.Index('datacamp-index')

# Upsert vector_set1 to namespace1
____(
  vectors=vector_set1,
  ____
)

# Upsert vector_set2 to namespace2
____(
  vectors=vector_set2,
  ____
)

# Print the index statistics
____
编辑并运行代码