Operations (sample payloads)

Main operations
Copy

Create index
Copy

This operation deploys a Pinecone index. This is where you specify the measure of similarity, the dimension of vectors to be stored in the index, which cloud provider you would like to deploy with, and more.

Sample Input

1
{
2
"name": "product-embeddings",
3
"dimension": 768,
4
"metric": "cosine",
5
"spec": {
6
"pod": {
7
"environment": "gcp-starter",
8
"pod_type": "p1.x1",
9
"replicas": 1,
10
"shards": 1,
11
"pods": 1,
12
"metadata_config": {
13
"indexed": [
14
"category",
15
"brand",
16
"price"
17
]
18
}
19
}
20
}
21
}

Sample Output

1
{
2
"name": "product-embeddings",
3
"dimension": 768,
4
"metric": "cosine",
5
"host": "product-embeddings-12345.svc.gcp-starter.pinecone.io",
6
"spec": {
7
"pod": {
8
"environment": "gcp-starter",
9
"replicas": 1,
10
"shards": 1,
11
"pod_type": "p1.x1",
12
"pods": 1,
13
"metadata_config": {
14
"indexed": [
15
"category",
16
"brand",
17
"price"
18
]
19
},
20
"source_collection": ""
21
}
22
},
23
"status": {
24
"ready": true,
25
"state": "Ready"
26
}
27
}

Delete vectors
Copy

The delete operation deletes vectors, by id, from a single namespace.

Sample Input

1
{
2
"index_host": "my-index-123456.svc.us-west1-gcp.pinecone.io",
3
"ids": [
4
"vec1",
5
"vec2",
6
"vec3"
7
],
8
"namespace": "product_catalog",
9
"filter": {
10
"category": "electronics",
11
"price": {
12
"$gt": 500
13
}
14
}
15
}

Sample Output

1
{
2
"deleted": true
3
}

Get index
Copy

Get a description of an index.

Sample Input

1
{
2
"index_name": "my-product-catalog"
3
}

Sample Output

1
{
2
"name": "my-product-catalog",
3
"dimension": 1536,
4
"metric": "cosine",
5
"host": "my-product-catalog-12345.svc.us-west1-gcp.pinecone.io",
6
"spec": {
7
"pod": {
8
"environment": "gcp-starter",
9
"replicas": 1,
10
"shard": 1,
11
"pod_type": "p1.x1",
12
"pods": 1,
13
"metadata_config": {
14
"indexed": [
15
"category",
16
"brand"
17
],
18
"source_collection": "products"
19
}
20
}
21
},
22
"status": {
23
"ready": true,
24
"state": "Ready"
25
}
26
}

Get index stats
Copy

The describe_index_stats operation returns statistics about the contents of an index, including the vector count per namespace and the number of dimensions, and the index fullness.

Sample Input

1
{
2
"index_host": "my-index-123456.svc.us-west1-gcp.pinecone.io",
3
"filter": {
4
"genre": "science fiction",
5
"year": {
6
"$gte": 2000
7
}
8
}
9
}

Sample Output

1
{
2
"namespaces": {
3
"default": {
4
"vector_count": 10000
5
},
6
"movies": {
7
"vector_count": 5000
8
}
9
},
10
"dimension": 1536,
11
"index_fullness": 0.75,
12
"total_vector_count": 15000
13
}

List indexes
Copy

This operation returns a list of all indexes in a project.

Sample Input

1
{}

Sample Output

1
{
2
"indexes": [
3
{
4
"name": "product-catalog",
5
"dimension": 512,
6
"metric": "cosine",
7
"host": "product-catalog-12345.svc.us-west1-gcp.pinecone.io",
8
"spec": {
9
"pod": {
10
"environment": "gcp-starter",
11
"replicas": 1,
12
"shards": 1,
13
"pod_type": "s1.x1",
14
"pods": 1,
15
"metadata_config": {
16
"indexed": [
17
"category",
18
"brand",
19
"price"
20
]
21
},
22
"source_collection": ""
23
}
24
},
25
"status": {
26
"ready": true,
27
"state": "Ready"
28
}
29
},
30
{
31
"name": "customer-embeddings",
32
"dimension": 768,
33
"metric": "euclidean",
34
"host": "customer-embeddings-67890.svc.us-east1-aws.pinecone.io",
35
"spec": {
36
"serverless": {
37
"cloud": "aws",
38
"region": "us-east-1"
39
}
40
},
41
"status": {
42
"ready": true,
43
"state": "Ready"
44
}
45
}
46
]
47
}

Query vectors
Copy

The query operation searches a namespace, using a query vector. It retrieves the ids of the most similar items in a namespace, along with their similarity scores.

Sample Input

1
{
2
"index_host": "my-index-123456.svc.us-west1-gcp.pinecone.io",
3
"namespace": "products",
4
"topK": 3,
5
"filter": {
6
"category": "electronics",
7
"price": {
8
"$lte": 1000
9
}
10
},
11
"includeValues": true,
12
"includeMetadata": true,
13
"vector": [
14
0.1,
15
0.2,
16
0.3,
17
0.4,
18
0.5
19
]
20
}

Sample Output

1
{
2
"matches": [
3
{
4
"id": "prod_001",
5
"score": 0.95,
6
"values": [
7
0.11,
8
0.21,
9
0.31,
10
0.41,
11
0.51
12
],
13
"metadata": {
14
"name": "Smartphone X",
15
"category": "electronics",
16
"price": 799.99
17
}
18
},
19
{
20
"id": "prod_002",
21
"score": 0.87,
22
"values": [
23
0.12,
24
0.22,
25
0.32,
26
0.42,
27
0.52
28
],
29
"metadata": {
30
"name": "Laptop Y",
31
"category": "electronics",
32
"price": 999.99
33
}
34
},
35
{
36
"id": "prod_003",
37
"score": 0.82,
38
"values": [
39
0.13,
40
0.23,
41
0.33,
42
0.43,
43
0.53
44
],
45
"metadata": {
46
"name": "Tablet Z",
47
"category": "electronics",
48
"price": 599.99
49
}
50
}
51
],
52
"namespace": "products",
53
"usage": {
54
"readUnits": 3
55
}
56
}

Upsert vectors
Copy

The upsert operation writes vectors into a namespace. If a new value is upserted for an existing vector id, it will overwrite the previous value.

Sample Input

1
{
2
"index_host": "my-index-123abc.svc.us-east-1-aws.pinecone.io",
3
"vectors": [
4
{
5
"id": "vec1",
6
"values": [
7
0.1,
8
0.2,
9
0.3,
10
0.4,
11
0.5
12
],
13
"sparseValues": {
14
"indices": [
15
1,
16
3,
17
5
18
],
19
"values": [
20
0.5,
21
0.8,
22
0.2
23
]
24
},
25
"metadata": {
26
"category": "electronics",
27
"price": 299.99
28
}
29
},
30
{
31
"id": "vec2",
32
"values": [
33
0.6,
34
0.7,
35
0.8,
36
0.9,
37
1
38
],
39
"metadata": {
40
"category": "clothing",
41
"size": "medium"
42
}
43
}
44
],
45
"namespace": "product_catalog"
46
}

Sample Output

1
{
2
"upsertedCount": 2
3
}