Skip to content

Commit e8d1fef

Browse files
authored
Merge pull request #56 from pinecone-io/feature/metadata-index-config
Adds the ability to specifiy metadata index configuration
2 parents fb61cc8 + b99e304 commit e8d1fef

File tree

6 files changed

+41
-7
lines changed

6 files changed

+41
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Added support of querying by a single vector.
66
- This is a step in deprecating batch queries.
77
- Added support of querying by vector id.
8+
- Adds support to specify what metadata fields should be indexed on index creation using the ```index_metadata_config``` option.
89

910
## [2.0.10](https://github.com/pinecone-io/pinecone-python-client/compare/v2.0.9...v2.0.10)
1011
### Changed

pinecone/core/client/model/create_request.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def openapi_types():
9595
'shards': (int,), # noqa: E501
9696
'pod_type': (str,), # noqa: E501
9797
'index_config': (dict,), # noqa: E501
98+
'metadata_index_config': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type,), # noqa: E501
9899
}
99100

100101
@cached_property
@@ -112,6 +113,7 @@ def discriminator():
112113
'shards': 'shards', # noqa: E501
113114
'pod_type': 'pod_type', # noqa: E501
114115
'index_config': 'index_config', # noqa: E501
116+
'metadata_index_config': 'metadata_index_config', # noqa: E501
115117
}
116118

117119
read_only_vars = {
@@ -166,6 +168,7 @@ def _from_openapi_data(cls, name, dimension, *args, **kwargs): # noqa: E501
166168
shards (int): The number of shards to be used in the index.. [optional] if omitted the server will use the default value of 1 # noqa: E501
167169
pod_type (str): The type of pod to use. One of 's1' or 'p1'.. [optional] if omitted the server will use the default value of "p1" # noqa: E501
168170
index_config (dict): [optional] # noqa: E501
171+
metadata_index_config ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type): Configuration for the behavior of Pinecone's internal metadata index. [optional] # noqa: E501
169172
"""
170173

171174
_check_type = kwargs.pop('_check_type', True)
@@ -260,6 +263,7 @@ def __init__(self, name, dimension, *args, **kwargs): # noqa: E501
260263
shards (int): The number of shards to be used in the index.. [optional] if omitted the server will use the default value of 1 # noqa: E501
261264
pod_type (str): The type of pod to use. One of 's1' or 'p1'.. [optional] if omitted the server will use the default value of "p1" # noqa: E501
262265
index_config (dict): [optional] # noqa: E501
266+
metadata_index_config ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type): Configuration for the behavior of Pinecone's internal metadata index. [optional] # noqa: E501
263267
"""
264268

265269
_check_type = kwargs.pop('_check_type', True)

pinecone/core/client/model/index_meta_database_status.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ class IndexMetaDatabaseStatus(ModelNormal):
6060
"""
6161

6262
allowed_values = {
63+
('state',): {
64+
'INITIALIZING': "Initializing",
65+
'SCALINGUP': "ScalingUp",
66+
'SCALINGDOWN': "ScalingDown",
67+
'TERMINATING': "Terminating",
68+
'READY': "Ready",
69+
},
6370
}
6471

6572
validations = {

pinecone/manage.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class IndexDescription(NamedTuple):
3030
pod_type: str
3131
index_config: None
3232
status: None
33+
metadata_index_config: None
3334

3435

3536
def _get_api_instance():
@@ -64,7 +65,8 @@ def create_index(
6465
shards: int = 1,
6566
pods: int = 1,
6667
pod_type: str = 'p1',
67-
index_config: dict = None
68+
index_config: dict = None,
69+
metadata_index_config: dict = None
6870
):
6971
"""Creates a Pinecone index.
7072
@@ -93,6 +95,8 @@ def create_index(
9395
:param pod_type: the pod type to be used for the index. can be one of p1 or s1.
9496
:type pod_type: str,optional
9597
:param index_config: Advanced configuration options for the index
98+
:param metadata_index_config: Configuration related to the metadata index
99+
:type metadata_index_config: dict, optional
96100
:type timeout: int, optional
97101
:param timeout: Timeout for wait until index gets ready. If None, wait indefinitely; if >=0, time out after this many seconds; if -1, return immediately and do not wait. Default: None
98102
"""
@@ -107,7 +111,8 @@ def create_index(
107111
shards=shards,
108112
pods=pods,
109113
pod_type=pod_type,
110-
index_config=index_config or {}
114+
index_config=index_config or {},
115+
metadata_index_config=metadata_index_config
111116
))
112117

113118
def is_ready():
@@ -181,7 +186,7 @@ def describe_index(name: str):
181186
return IndexDescription(name=db['name'], index_type=db['index_type'], metric=db['metric'],
182187
replicas=db['replicas'], dimension=db['dimension'], shards=db['shards'],
183188
pods=db.get('pods', db['shards']*db['replicas']), pod_type=db.get('pod_type', 'p1'),
184-
index_config=db['index_config'], status={'ready': ready, 'state': state})
189+
index_config=db['index_config'], status={'ready': ready, 'state': state}, metadata_index_config=db.get('metadata_index_config'))
185190

186191

187192
def scale_index(name: str, replicas: int):

specs/index_service.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@
267267
"default": 1
268268
},
269269
"pod_type": {
270-
"type" : "string",
270+
"type": "string",
271271
"description": "The type of pod to use. One of 's1' or 'p1'.",
272272
"default": "p1"
273273
},
@@ -277,6 +277,11 @@
277277
"$ref": "#/components/schemas/ApproximatedConfig"
278278
}
279279
]
280+
},
281+
"metadata_index_config": {
282+
"type": "object",
283+
"description": "Configuration for the behavior of Pinecone's internal metadata index",
284+
"nullable": true
280285
}
281286
}
282287
},
@@ -317,7 +322,7 @@
317322
}
318323
]
319324
},
320-
"status" : {
325+
"status": {
321326
"type": "object",
322327
"properties": {
323328
"ready": {
@@ -394,4 +399,4 @@
394399
"description": "More Pinecone.io API docs",
395400
"url": "https://www.pinecone.io/docs"
396401
}
397-
}
402+
}

specs/pinecone_api.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,11 @@
11511151
"$ref": "#/components/schemas/ApproximatedConfig"
11521152
}
11531153
]
1154+
},
1155+
"metadata_index_config": {
1156+
"type": "object",
1157+
"description": "Configuration for the behavior of Pinecone's internal metadata index",
1158+
"nullable": true
11541159
}
11551160
}
11561161
},
@@ -1198,7 +1203,14 @@
11981203
"type": "boolean"
11991204
},
12001205
"state": {
1201-
"type": "string"
1206+
"type": "string",
1207+
"enum": [
1208+
"Initializing",
1209+
"ScalingUp",
1210+
"ScalingDown",
1211+
"Terminating",
1212+
"Ready"
1213+
]
12021214
}
12031215
}
12041216
}

0 commit comments

Comments
 (0)