Skip to content

Commit

Permalink
Merge pull request #987 from milvus-io/restful25
Browse files Browse the repository at this point in the history
Restful25
  • Loading branch information
AnthonyTsu1984 authored Feb 8, 2025
2 parents 6ff6692 + 03ba75c commit 7356b0e
Show file tree
Hide file tree
Showing 14 changed files with 174 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# alter_collection_field()

This operation changes the specified collection field parameters.

## Request Syntax

```python
alter_collection_field(
collection_name: str,
field_name: str,
field_params: Dict,
db_name="",
timeout: Optional[float] = None,
**kwargs,
)
```

**PARAMETERS:**

- **collection_name** (*str*) -

The name of the target collection.

- **field_name** (*str*) -

The name of the target field.

- **field_params** (*dict*) -

The field parameters to change. The properties not mentioned remains unchanged. Possible parameters vary with the field type.

- **is_primary** (*bool*) -

Whether the current field is the primary field in a collection.

<div class="admonition note">

<p><b>notes</b></p>

<ul>
<li><p>Each collection has only one primary field.</p></li>
<li><p>A primary field should be of either the <strong>DataType.INT64</strong> type or the <strong>DataType.VARCHAR</strong> type.</p></li>
</ul>

</div>

- **max_length** (*int*) -

The maximum byte length for strings allowed to be inserted. Note that multibyte characters (e.g., Unicode characters) may occupy more than one byte each, so ensure the byte length of inserted strings does not exceed the specified limit. Value range: [1, 65,535].

This is mandatory for a **DataType.VARCHAR** field.

- **element_type** (*str*) -

The data type of the elements in the field value.

This is mandatory for a **DataType.ARRAY** field.

- **max_capacity** (*int*) -

The number of elements in an Array field value.

This is mandatory for a **DataType.ARRAY** field.

- **dim** (*int*) -

The dimension of the vector embeddings. The value should be an integer greater than 1.

This is mandatory for a field of the **DataType.FLOAT_VECTOR**, **DataType.BINARY_VECTOR**, **DataType.FLOAT16_VECTOR**, or **DataType.BFLOAT16_VECTOR** type. If you use **DataType.SPARSE_FLOAT_VECTOR**, omit this parameter.

- **is_partition_key** (*bool*) -

Whether the current field serves as the partition key. Each collection can have one partition key.

This parameter is not applicable to Milvus Lite. For more information on Milvus Lite limits, refer to [Run Milvus Lite](https://milvus.io/docs/milvus_lite.md).

<div class="admonition note">

<p><b>what is the partition key?</b></p>

<p>To facilitate partition-oriented multi-tenancy, you can set a field as the partition key field so that Milvus hashes the field values and distributes entities among the specified number of partitions accordingly.</p>
<p>When retrieving entities, ensure that the partition key field is used in the boolean expression to filter out entities of a specific field value.</p>
<p>For details, refer to <a href="https://milvus.io/docs/use-partition-key">Use Partition Key</a> and <a href="https://milvus.io/docs/multi_tenancy.md">Multi-tenancy</a>.</p>

</div>

- **is_clustering_key** (*bool*) -

Whether the current field serves as the clustering key. Each collection can have one partition key. You can also use the partition key as the clustering key. For details, refer to Clustering Compaction.

- **mmap_enabled** (*bool*) -

Whether Milvus maps the field data into memory instead of fully loading it. For details settings, refer to MMap-enabled Data Storage.

- **timeout** (*Optional[float]*) -

The timeout duration for this operation.

Setting this to None indicates that this operation timeouts when any response arrives or any error occurs.

**RETURN TYPE:**

*NoneType*

**RETURNS:**

*None*

**EXCEPTIONS:**

- **MilvusException**

This exception will be raised when any error occurs during this operation, especially when the specified alias does not exist.

## Example

```python
from pymilvus import MilvusClient

# 1. Create a milvus client
client = MilvusClient(
uri="http://localhost:19530",
token="root:Milvus"
)

# upsert properties
field_params = {"max_length": 1500}

client.alter_collection_field(
collection_name="collection_name",
field_name="my_varchar",
field_params=field_params
)
```

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ import RestSpecs from '@site/src/components/RestSpecs';

<RestSpecs specs={specs} endpoint={endpoint} method={method} target="milvus" lang="en-US" />

export const specs = {"summary":"Create Index","deprecated":false,"description":"This creates a named index for a target field, which can either be a vector field or a scalar field.","x-i18n":{"zh-CN":{"summary":"创建索引","description":"为指定的向量字段或标量字段创建一个索引并为其命名。"}},"tags":["Index Operations (V2)"],"parameters":[{"name":"Authorization","in":"header","description":"The authentication token should be <include target=\"zilliz\">an API key with appropriate privileges or </include>a pair of colon-joined username and password, like `username:password`.","required":true,"example":"Bearer {{TOKEN}}","schema":{"type":"string"},"x-i18n":{"zh-CN":{"description":"认证令牌,应为<include target=\"zilliz\">具备适当权限的 API 密钥或</include>用冒号分隔的用户名和密码,如 `username:password`。"}}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"dbName":{"type":"string","description":"The name of the database that to which the collection belongs .\nSetting this to a non-existing database results in an error.","x-i18n":{"zh-CN":{"description":"Collection 所属的数据库名称。设置为不存在的数据库将导致错误。"}}},"collectionName":{"type":"string","description":"The name of the target collection.\nSetting this to a non-existing collection results in an error.","x-i18n":{"zh-CN":{"description":"目标 Collection 的名称。设置为不存在的 Collection 将导致错误。"}}},"indexParams":{"type":"array","items":{"type":"object","description":"Index parameters for a specific field.","x-i18n":{"zh-CN":{"descripiton":"针对某一字段的索引参数。"}},"properties":{"metricType":{"type":"string","description":"The similarity metric type used to build the index. For more information, refer to [Similarity Metrics Explained](/docs/search-metrics-explained).","x-i18n":{"zh-CN":{"description":"用于构建索引的相似度类型。更多详情,请参考[相似度类型](/docs/search-metrics-explained)。"}},"enum":["L2","IP","COSINE"],"default":"COSINE"},"fieldName":{"type":"string","description":"The name of the target field on which an index is to be created.","x-i18n":{"zh-CN":{"description":"要创建索引的目标字段名称。"}}},"indexName":{"type":"string","description":"The name of the index to create. The value defaults to the target field name.","x-i18n":{"zh-CN":{"description":"要创建的索引的名称,该值默认为目标字段名称。"}}},"params":{"description":"The index type and related settings. For details, refer to [Vector Indexes](https://milvus.io/docs/index.md).","x-i18n":{"zh-CN":{"description":"索引类型及相关设置。详细信息,请参阅 [向量索引](https://milvus.io/docs/index.md)。"}},"type":"object","properties":{"index_type":{"type":"string","description":"The type of the index to create","x-i18n":{"zh-CN":{"description":"要创建的索引类型。"}}},"M":{"type":"integer","description":"The maximum degree of the node. This applies only when **index_type** is set to **HNSW**.","x-i18n":{"zh-CN":{"description":"数据节点与其他节点连接的边数。此参数仅适用于**索引类型**为 **HNSW** 的情况。"}}},"efConstruction":{"type":"integer","description":"The search scope. This applies only when **index_type** is set to **HNSW**.","x-i18n":{"zh-CN":{"description":"搜索范围。此参数仅适用于**索引类型**为 **HNSW** 的情况。"}}},"nlist":{"type":"integer","description":"The number of cluster units. This applies only when **index_type** is set to **IVF**-related index types.","x-i18n":{"zh-CN":{"description":"数据集群单元的数量。此参数仅适用于**索引类型**为 **IVF** 系列索引的情况。"}}}},"x-i18n-langs":["zh-CN"],"required":["index_type"]}},"x-i18n-langs":["zh-CN"],"required":["metricType","fieldName","indexName"]},"description":"The parameters that apply to the index-building process.","x-i18n":{"zh-CN":{"description":"应用于索引构建过程的参数。"}}}},"required":["indexParams","collectionName"],"x-i18n-langs":["zh-CN"]},"example":{"collectionName":"custom_setup_not_indexed","indexParams":[{"metricType":"L2","fieldName":"my_vector","indexName":"my_vector","indexConfig":{"index_type":"AUTOINDEX"}}]}}}},"responses":{"200":{"description":"None","content":{"application/json":{"schema":{"oneOf":[{"x-tab-label":"success","description":"A success response","x-i18n":{"zh-CN":{"description":"成功响应。"}},"x-i18n-langs":["zh-CN"],"type":"object","properties":{"code":{"description":"Response code.","x-i18n":{"zh-CN":{"description":"响应码。"}},"type":"integer"},"data":{"type":"object","properties":{},"description":"Response payload which is an empty object.","x-i18n":{"zh-CN":{"description":"响应载荷。为空对象。"}}}}},{"x-tab-label":"failure","description":"A failure response.","x-i18n":{"zh-CN":{"description":"失败响应。"}},"x-i18n-langs":["zh-CN"],"type":"object","properties":{"code":{"type":"integer","description":"Response code.","x-i18n":{"zh-CN":{"description":"响应码。"}}},"message":{"type":"string","description":"Error message.","x-i18n":{"zh-CN":{"description":"错误描述。"}}}}}]},"examples":{"1":{"summary":"success","x-target-response":"OPTION 1","value":{"code":0,"data":{}}},"2":{"summary":"failure","x-target-response":"OPTION 2","value":{"code":1800,"message":"User hasn't authenticated"}}}}}}},"security":[]}
export const specs = {"summary":"Create Index","deprecated":false,"description":"This creates a named index for a target field, which can either be a vector field or a scalar field.","x-i18n":{"zh-CN":{"summary":"创建索引","description":"为指定的向量字段或标量字段创建一个索引并为其命名。"}},"tags":["Index Operations (V2)"],"parameters":[{"name":"Authorization","in":"header","description":"The authentication token should be <include target=\"zilliz\">an API key with appropriate privileges or </include>a pair of colon-joined username and password, like `username:password`.","required":true,"example":"Bearer {{TOKEN}}","schema":{"type":"string"},"x-i18n":{"zh-CN":{"description":"认证令牌,应为<include target=\"zilliz\">具备适当权限的 API 密钥或</include>用冒号分隔的用户名和密码,如 `username:password`。"}}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"dbName":{"type":"string","description":"The name of the database that to which the collection belongs .\nSetting this to a non-existing database results in an error.","x-i18n":{"zh-CN":{"description":"Collection 所属的数据库名称。设置为不存在的数据库将导致错误。"}}},"collectionName":{"type":"string","description":"The name of the target collection.\nSetting this to a non-existing collection results in an error.","x-i18n":{"zh-CN":{"description":"目标 Collection 的名称。设置为不存在的 Collection 将导致错误。"}}},"indexParams":{"type":"array","items":{"type":"object","description":"Index parameters for a specific field.","x-i18n":{"zh-CN":{"descripiton":"针对某一字段的索引参数。"}},"properties":{"index_type":{"type":"string","description":"The type of the index to create","x-i18n":{"zh-CN":{"description":"要创建的索引类型。"}}},"metricType":{"type":"string","description":"The similarity metric type used to build the index. For more information, refer to [Similarity Metrics Explained](/docs/search-metrics-explained).","x-i18n":{"zh-CN":{"description":"用于构建索引的相似度类型。更多详情,请参考[相似度类型](/docs/search-metrics-explained)。"}},"enum":["L2","IP","COSINE"],"default":"COSINE"},"fieldName":{"type":"string","description":"The name of the target field on which an index is to be created.","x-i18n":{"zh-CN":{"description":"要创建索引的目标字段名称。"}}},"indexName":{"type":"string","description":"The name of the index to create. The value defaults to the target field name.","x-i18n":{"zh-CN":{"description":"要创建的索引的名称,该值默认为目标字段名称。"}}},"params":{"description":"The index type and related settings. For details, refer to [Vector Indexes](https://milvus.io/docs/index.md).","x-i18n":{"zh-CN":{"description":"索引类型及相关设置。详细信息,请参阅 [向量索引](https://milvus.io/docs/index.md)。"}},"type":"object","properties":{"M":{"type":"integer","description":"The maximum degree of the node. This applies only when **index_type** is set to **HNSW**.","x-i18n":{"zh-CN":{"description":"数据节点与其他节点连接的边数。此参数仅适用于**索引类型**为 **HNSW** 的情况。"}}},"efConstruction":{"type":"integer","description":"The search scope. This applies only when **index_type** is set to **HNSW**.","x-i18n":{"zh-CN":{"description":"搜索范围。此参数仅适用于**索引类型**为 **HNSW** 的情况。"}}},"nlist":{"type":"integer","description":"The number of cluster units. This applies only when **index_type** is set to **IVF**-related index types.","x-i18n":{"zh-CN":{"description":"数据集群单元的数量。此参数仅适用于**索引类型**为 **IVF** 系列索引的情况。"}}}},"x-i18n-langs":["zh-CN"],"required":["index_type"]}},"x-i18n-langs":["zh-CN"],"required":["metricType","fieldName","indexName"]},"description":"The parameters that apply to the index-building process.","x-i18n":{"zh-CN":{"description":"应用于索引构建过程的参数。"}}}},"required":["indexParams","collectionName"],"x-i18n-langs":["zh-CN"]},"example":{"collectionName":"custom_setup_not_indexed","indexParams":[{"index_type":"AUTOINDEX","metricType":"L2","fieldName":"my_vector","indexName":"my_vector"}]}}}},"responses":{"200":{"description":"None","content":{"application/json":{"schema":{"oneOf":[{"x-tab-label":"success","description":"A success response","x-i18n":{"zh-CN":{"description":"成功响应。"}},"x-i18n-langs":["zh-CN"],"type":"object","properties":{"code":{"description":"Response code.","x-i18n":{"zh-CN":{"description":"响应码。"}},"type":"integer"},"data":{"type":"object","properties":{},"description":"Response payload which is an empty object.","x-i18n":{"zh-CN":{"description":"响应载荷。为空对象。"}}}}},{"x-tab-label":"failure","description":"A failure response.","x-i18n":{"zh-CN":{"description":"失败响应。"}},"x-i18n-langs":["zh-CN"],"type":"object","properties":{"code":{"type":"integer","description":"Response code.","x-i18n":{"zh-CN":{"description":"响应码。"}}},"message":{"type":"string","description":"Error message.","x-i18n":{"zh-CN":{"description":"错误描述。"}}}}}]},"examples":{"1":{"summary":"success","x-target-response":"OPTION 1","value":{"code":0,"data":{}}},"2":{"summary":"failure","x-target-response":"OPTION 2","value":{"code":1800,"message":"User hasn't authenticated"}}}}}}},"security":[]}
export const endpoint = "/v2/vectordb/indexes/create"
export const method = "post"
Loading

0 comments on commit 7356b0e

Please sign in to comment.