alterCollection()

This operation alters the properties of a specified collection.

Deprecated. Replaced by alterCollectionProperties() since SDK v2.5.3, to keep consistency with other SDKs.

public void alterCollection(AlterCollectionReq request)

Request Syntax

alterCollection(AlterCollectionReq.builder()
    .databaseName(String databaseName)
    .collectionName(String collectionName)
    .properties(Map<String, String> properties)
    .build()
)

BUILDER METHODS:

  • databaseName(String databaseName)

    The name of the database that holds the target collection.

  • collectionName(String collectionName)

    The name of the target collection.

  • properties(Map<String, String> properties)

    The properties to modify and their expected values. Note that the property values should be strings. Available database properties are as follows:

    • collection.ttl.seconds -

      The time-to-live (TTL) of a collection in seconds.

    • mmap.enabled -

      Whether to enable mmap for the raw data and indexes of all fields in the collection.

RETURNS:

void

EXCEPTIONS:

Example

import io.milvus.v2.client.ConnectConfig;
import io.milvus.v2.client.MilvusClientV2;
import io.milvus.v2.service.collection.request.AlterCollectionReq;
import java.util.HashMap;
import java.util.Map;

// 1. Set up a client
ConnectConfig connectConfig = ConnectConfig.builder()
        .uri("http://localhost:19530")
        .token("root:Milvus")
        .build();

MilvusClientV2 client = new MilvusClientV2(connectConfig);

// 2. Alter collection properties
Map<String, String> properties = new HashMap<>();
properties.put("collection.ttl.seconds", "1000");
client.alterCollection(AlterCollectionReq.builder()
        .collectionName("my_collection")
        .properties(properties)
        .build());

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?