索引管理

使用 Pinecone 構建 AI 應用

James Chapman

Curriculum Manager, DataCamp

連線到索引

pc = Pinecone(api_key="API_KEY")

pc.create_index(
    name='datacamp-index',
    dimension=1536,
    spec=ServerlessSpec(
        cloud='aws', 
        region='us-east-1'
    )
)


index = pc.Index('datacamp-index')
使用 Pinecone 構建 AI 應用

連線到索引

index = pc.Index('datacamp-first')
...
pinecone.core.client.exceptions.NotFoundException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'content-type': 'text/plain; charset=...
HTTP response body: {"error":{"code":"NOT_FOUND","message":"Resource datacamp-first
not found"},"status":404}
使用 Pinecone 構建 AI 應用

索引統計

index.describe_index_stats()
{'dimension': 1536,
 'index_fullness': 0.0,
 'namespaces': {},
 'total_vector_count': 0}
使用 Pinecone 構建 AI 應用

命名空間

 

  • 用來「分割」索引的容器
    • 分開不同資料集
    • 資料版控
    • 分離群組

 

先聚焦單一命名空間情境

包含多個命名空間的索引。

使用 Pinecone 構建 AI 應用

Organizations

一個組織包含兩個專案,各自擁有自己的索引。

使用 Pinecone 構建 AI 應用

Organizations

一組組織擁有者。

  • 權限涵蓋整個組織。
  • 管理帳單、使用者、所有專案

一位擁有者底下有多位使用者。

  • 受限的組織層級權限
  • 受邀加入特定專案
  • 於該等專案成為擁有者
使用 Pinecone 構建 AI 應用

刪除索引

pc.delete_index('datacamp-index')


pc.list_indexes()
{'indexes': []}
使用 Pinecone 構建 AI 應用

一起來練習吧!

使用 Pinecone 構建 AI 應用

Preparing Video For Download...