跳到主要内容

备份索引

本文档描述如何使用集合备份索引。

要了解如何从集合创建索引,请参阅管理索引

⚠️警告

本文档使用集合。这是一个公开预览功能。在使用此功能生产负载之前,请进行充分测试。

使用集合创建备份

要创建索引的备份,请使用create_collection操作。集合是索引的静态副本,仅消耗存储空间。

示例

以下示例从名为example-index的索引创建名为example-collection的集合。

下面分别是Python、JavaScript和Curl代码

pinecone.create_collection("example-collection", "example-index")

await pinecone.createCollection({
name: "example-collection",
source: "example-index",
});

curl -i -X POST https://controller.us-west1-gcp.pinecone.io/collections \
-H 'Api-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"name": "example-collection",
"source": "example-index"
}'

检查集合的状态

要检索创建集合的过程状态和集合的大小,请使用describe_collection操作。指定要检查的集合的名称。只能在当前项目中调用describe_collection对集合进行描述。

describe_collection操作返回一个对象,其中包含表示集合名称、字节数和集合创建状态的键值对。

示例

以下示例获取名为example-collection的集合的创建状态和大小。 下面分别是Python、JavaScript和Curl代码

pinecone.describe_collection("example-collection")

const collectionDescription = await pinecone.describeCollection(
"example-collection"
);
console.log(collectionDescription.data);

curl -i -X GET https://controller.us-west1-gcp.pinecone.io/collections/example-collection \
-H 'Api-Key: YOUR_API_KEY'

结果:

Shell

CollectionDescription(name='test-collection', size=3818809, status='Ready')

列出您的集合

要获取当前项目中集合列表,请使用list_collections操作。

示例

以下示例会获取当前项目中的所有集合列表。

下面分别是Python、JavaScript和Curl代码

pinecone.list_collections()

const collections = await pinecone.listCollections();
console.log(collections.data);

curl -i -X GET https://controller.us-west1-gcp.pinecone.io/collections \
-H 'Api-Key: YOUR_API_KEY'

结果

Shell

example-collection

删除一个集合

要删除集合,请使用delete_collection操作。指定要删除的集合的名称。

删除集合需要几分钟时间。在此期间,describe_collection操作将返回状态"deleting"

示例

以下示例删除了集合example-collection

下面分别是Python、JavaScript和Curl代码

pinecone.delete_collection("example-collection")

await pinecone.deleteCollection("example-collection");

curl -i -X DELETE https://controller.us-west1-gcp.pinecone.io/collections/example-collection \
-H 'Api-Key: YOUR_API_KEY'

更新于 4个月前