跳到主要内容
版本:v3.0.x

addCollectionFunction()

Adds a function definition to an existing collection. In Milvus 3.0, use addFunctionField() when the function output field and its index must be added together.

Java
public void addCollectionFunction(AddCollectionFunctionReq request)

Request Syntax

Java
AddCollectionFunctionReq.builder()
.collectionName(collectionName)
.databaseName(databaseName)
.function(function)
.build();

BUILDER METHODS:

  • collectionName(String collectionName)

    The name of the target collection.

  • databaseName(String databaseName)

    The name of the database. Defaults to the current database when omitted.

  • function(CreateCollectionReq.Function function)

    The function definition to add to existing collection fields.

RETURNS:

void

This operation does not return a value.

EXCEPTIONS:

  • MilvusClientException

    Raised when request validation, transport, or server execution fails. Inspect the exception message for the exact failure reason.

Example

Java
CreateCollectionReq.Function bm25Function = CreateCollectionReq.Function.builder()
.name("bm25")
.functionType(FunctionType.BM25)
.inputFieldNames(Collections.singletonList("text"))
.outputFieldNames(Collections.singletonList("sparse"))
.build();

client.addCollectionFunction(AddCollectionFunctionReq.builder()
.collectionName("books")
.function(bm25Function)
.build());