pinecone.models
1from .index_description import ServerlessSpecDefinition, PodSpecDefinition 2from .collection_description import CollectionDescription 3from .serverless_spec import ServerlessSpec 4from .pod_spec import PodSpec 5from .index_list import IndexList 6from .collection_list import CollectionList 7from .index_model import IndexModel 8 9__all__ = [ 10 "CollectionDescription", 11 "PodSpec", 12 "PodSpecDefinition", 13 "ServerlessSpec", 14 "ServerlessSpecDefinition", 15 "IndexList", 16 "CollectionList", 17 "IndexModel", 18]
5class CollectionDescription(NamedTuple): 6 """ 7 The description of a collection. 8 """ 9 10 name: str 11 """ 12 The name of the collection. 13 """ 14 15 source: str 16 """ 17 The name of the index used to create the collection. 18 """
The description of a collection.
Create new instance of CollectionDescription(name, source)
Inherited Members
- builtins.tuple
- index
- count
5class PodSpec(NamedTuple): 6 """ 7 PodSpec represents the configuration used to deploy a pod-based index. 8 9 To learn more about the options for each configuration, please see [Understanding Indexes](https://docs.pinecone.io/docs/indexes) 10 """ 11 12 environment: str 13 """ 14 The environment where the pod index will be deployed. Example: 'us-east1-gcp' 15 """ 16 17 replicas: Optional[int] = None 18 """ 19 The number of replicas to deploy for the pod index. Default: 1 20 """ 21 22 shards: Optional[int] = None 23 """ 24 The number of shards to use. Shards are used to expand the amount of vectors you can store beyond the capacity of a single pod. Default: 1 25 """ 26 27 pods: Optional[int] = None 28 """ 29 Number of pods to deploy. Default: 1 30 """ 31 32 pod_type: Optional[str] = "p1.x1" 33 """ 34 This value combines pod type and pod size into a single string. This configuration is your main lever for vertical scaling. 35 """ 36 37 metadata_config: Optional[Dict] = {} 38 """ 39 If you are storing a lot of metadata, you can use this configuration to limit the fields which are indexed for search. 40 41 This configuration should be a dictionary with the key 'indexed' and the value as a list of fields to index. 42 43 For example, if your vectors have metadata along like this: 44 45 ```python 46 from pinecone import Vector 47 48 vector = Vector( 49 id='237438191', 50 values=[...], 51 metadata={ 52 'productId': '237438191', 53 'description': 'Stainless Steel Tumbler with Straw', 54 'category': 'kitchen', 55 'price': '19.99' 56 } 57 ) 58 ``` 59 60 You might want to limit which fields are indexed with metadata config such as this: 61 ``` 62 {'indexed': ['field1', 'field2']} 63 """ 64 65 source_collection: Optional[str] = None 66 """ 67 The name of the collection to use as the source for the pod index. This configuration is only used when creating a pod index from an existing collection. 68 """ 69 70 def asdict(self): 71 """ 72 Returns the PodSpec as a dictionary. 73 """ 74 return {"pod": self._asdict()}
PodSpec represents the configuration used to deploy a pod-based index.
To learn more about the options for each configuration, please see Understanding Indexes
Create new instance of PodSpec(environment, replicas, shards, pods, pod_type, metadata_config, source_collection)
The number of shards to use. Shards are used to expand the amount of vectors you can store beyond the capacity of a single pod. Default: 1
This value combines pod type and pod size into a single string. This configuration is your main lever for vertical scaling.
If you are storing a lot of metadata, you can use this configuration to limit the fields which are indexed for search.
This configuration should be a dictionary with the key 'indexed' and the value as a list of fields to index.
For example, if your vectors have metadata along like this:
from pinecone import Vector
vector = Vector(
id='237438191',
values=[...],
metadata={
'productId': '237438191',
'description': 'Stainless Steel Tumbler with Straw',
'category': 'kitchen',
'price': '19.99'
}
)
You might want to limit which fields are indexed with metadata config such as this: ``` {'indexed': ['field1', 'field2']}
The name of the collection to use as the source for the pod index. This configuration is only used when creating a pod index from an existing collection.
70 def asdict(self): 71 """ 72 Returns the PodSpec as a dictionary. 73 """ 74 return {"pod": self._asdict()}
Returns the PodSpec as a dictionary.
Inherited Members
- builtins.tuple
- index
- count
5class PodSpecDefinition(NamedTuple): 6 replicas: int 7 shards: int 8 pods: int 9 pod_type: str 10 environment: str 11 metadata_config: Optional[Dict]
PodSpecDefinition(replicas, shards, pods, pod_type, environment, metadata_config)
Create new instance of PodSpecDefinition(replicas, shards, pods, pod_type, environment, metadata_config)
Inherited Members
- builtins.tuple
- index
- count
5class ServerlessSpec(NamedTuple): 6 cloud: str 7 region: str 8 9 def asdict(self): 10 return {"serverless": self._asdict()}
ServerlessSpec(cloud, region)
Inherited Members
- builtins.tuple
- index
- count
ServerlessSpecDefinition(cloud, region)
Create new instance of ServerlessSpecDefinition(cloud, region)
Inherited Members
- builtins.tuple
- index
- count
7class IndexList: 8 def __init__(self, index_list: OpenAPIIndexList): 9 self.index_list = index_list 10 self.indexes = [IndexModel(i) for i in self.index_list.indexes] 11 self.current = 0 12 13 def names(self): 14 return [i.name for i in self.indexes] 15 16 def __getitem__(self, key): 17 return self.indexes[key] 18 19 def __len__(self): 20 return len(self.indexes) 21 22 def __iter__(self): 23 return iter(self.indexes) 24 25 def __str__(self): 26 return str(self.indexes) 27 28 def __repr__(self): 29 return json.dumps([i.to_dict() for i in self.indexes], indent=4) 30 31 def __getattr__(self, attr): 32 return getattr(self.index_list, attr)
6class CollectionList: 7 """ 8 A list of collections. 9 """ 10 11 def __init__(self, collection_list: OpenAPICollectionList): 12 self.collection_list = collection_list 13 self.current = 0 14 15 def names(self): 16 return [i["name"] for i in self.collection_list.collections] 17 18 def __getitem__(self, key): 19 return self.collection_list.collections[key] 20 21 def __len__(self): 22 return len(self.collection_list.collections) 23 24 def __iter__(self): 25 return iter(self.collection_list.collections) 26 27 def __str__(self): 28 return str(self.collection_list) 29 30 def __repr__(self): 31 return json.dumps([c.to_dict() for c in self.collection_list.collections], indent=4) 32 33 def __getattr__(self, attr): 34 return getattr(self.collection_list, attr)
A list of collections.
5class IndexModel: 6 def __init__(self, index: OpenAPIIndexModel): 7 self.index = index 8 self.deletion_protection = index.deletion_protection.value 9 10 def __str__(self): 11 return str(self.index) 12 13 def __getattr__(self, attr): 14 return getattr(self.index, attr) 15 16 def __getitem__(self, key): 17 return self.__getattr__(key) 18 19 def to_dict(self): 20 return self.index.to_dict()