io.milvus.v2.client

## Class MilvusClientV2

- java.lang.Object
- - io.milvus.v2.client.MilvusClientV2

    public class MilvusClientV2
    extends java.lang.Object

### Constructor Summary

Constructors
Constructor and Description
`MilvusClientV2(ConnectConfig connectConfig)` Creates a Milvus client instance.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `alterAlias(AlterAliasReq request)` alter aliases
`void` `alterCollection(AlterCollectionReq request)` Alter a collection in Milvus.
`void` `alterDatabase(AlterDatabaseReq request)` Alter database with key value pair.
`void` `alterIndex(AlterIndexReq request)` Alter an index in Milvus.
`boolean` `clientIsReady()`
`void` `close()` Disconnects from a Milvus server with timeout of 1 second
`void` `close(long maxWaitSeconds)` Disconnects from a Milvus server with configurable timeout
`void` `createAlias(CreateAliasReq request)` create aliases
`void` `createCollection(CreateCollectionReq request)` Creates a collection in Milvus.
`void` `createDatabase(CreateDatabaseReq request)` Creates a database in Milvus.
`void` `createIndex(CreateIndexReq request)` Creates an index for a specified field in a collection in Milvus.
`void` `createPartition(CreatePartitionReq request)` Creates a partition in a collection in Milvus.
`void` `createRole(CreateRoleReq request)` create role
`CreateCollectionReq.CollectionSchema` `createSchema()` Creates a collection schema.
`void` `createUser(CreateUserReq request)` create user
`DeleteResp` `delete(DeleteReq request)` Deletes vectors in a collection in Milvus.
`DescribeAliasResp` `describeAlias(DescribeAliasReq request)` describe aliases
`DescribeCollectionResp` `describeCollection(DescribeCollectionReq request)` Gets the collection info in Milvus.
`DescribeDatabaseResp` `describeDatabase(DescribeDatabaseReq request)` Show detail of database base, such as replica number and resource groups.
`DescribeIndexResp` `describeIndex(DescribeIndexReq request)` Checks whether an index exists for a specified field in a collection in Milvus.
`DescribeRoleResp` `describeRole(DescribeRoleReq request)` describe role
`DescribeUserResp` `describeUser(DescribeUserReq request)` describe user
`void` `dropAlias(DropAliasReq request)` drop aliases
`void` `dropCollection(DropCollectionReq request)` Drops a collection in Milvus.
`void` `dropDatabase(DropDatabaseReq request)` Drops a database.
`void` `dropIndex(DropIndexReq request)` Drops an index for a specified field in a collection in Milvus.
`void` `dropPartition(DropPartitionReq request)` Drops a partition in a collection in Milvus.
`void` `dropRole(DropRoleReq request)` drop role
`void` `dropUser(DropUserReq request)` drop user
`GetResp` `get(GetReq request)` Gets vectors in a collection in Milvus.
`GetCollectionStatsResp` `getCollectionStats(GetCollectionStatsReq request)` get collection stats for a collection in Milvus.
`java.lang.Boolean` `getLoadState(GetLoadStateReq request)` Checks whether a collection is loaded in Milvus.
`java.lang.String` `getServerVersion()` Get server version
`void` `grantPrivilege(GrantPrivilegeReq request)` grant privilege
`void` `grantRole(GrantRoleReq request)` grant role
`java.lang.Boolean` `hasCollection(HasCollectionReq request)` Checks whether a collection exists in Milvus.
`java.lang.Boolean` `hasPartition(HasPartitionReq request)` Checks whether a partition exists in a collection in Milvus.
`SearchResp` `hybridSearch(HybridSearchReq request)` Conducts multi vector similarity search with a ranker for rearrangement.
`InsertResp` `insert(InsertReq request)` Inserts vectors into a collection in Milvus.
`ListAliasResp` `listAliases(ListAliasesReq request)` list aliases
`ListCollectionsResp` `listCollections()` list milvus collections
`ListDatabasesResp` `listDatabases()` List all databases.
`java.util.List<java.lang.String>` `listIndexes(ListIndexesReq request)` Lists all indexes in a collection in Milvus.
`java.util.List<java.lang.String>` `listPartitions(ListPartitionsReq request)` Lists all partitions in a collection in Milvus.
`java.util.List<java.lang.String>` `listRoles()` list roles
`java.util.List<java.lang.String>` `listUsers()` list users
`void` `loadCollection(LoadCollectionReq request)` Loads a collection into memory in Milvus.
`void` `loadPartitions(LoadPartitionsReq request)` Loads partitions in a collection in Milvus.
`QueryResp` `query(QueryReq request)` Queries vectors in a collection in Milvus.
`QueryIterator` `queryIterator(QueryIteratorReq request)` Get queryIterator based on scalar field(s) filtered by boolean expression.
`void` `releaseCollection(ReleaseCollectionReq request)` Releases a collection from memory in Milvus.
`void` `releasePartitions(ReleasePartitionsReq request)` Releases partitions in a collection in Milvus.
`void` `renameCollection(RenameCollectionReq request)` rename collection in a collection in Milvus.
`void` `retryConfig(RetryConfig retryConfig)`
`void` `revokePrivilege(RevokePrivilegeReq request)` revoke privilege
`void` `revokeRole(RevokeRoleReq request)` revoke role
`SearchResp` `search(SearchReq request)` Searches vectors in a collection in Milvus.
`SearchIterator` `searchIterator(SearchIteratorReq request)` Get searchIterator based on a vector field.
`void` `updatePassword(UpdatePasswordReq request)` change password
`UpsertResp` `upsert(UpsertReq request)` Upsert vectors into a collection in Milvus.
`void` `useDatabase(@NonNull java.lang.String dbName)` use Database

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### MilvusClientV2

    public MilvusClientV2(ConnectConfig connectConfig)

Creates a Milvus client instance.

Parameters:
  `connectConfig` - Milvus server connection configuration

### Method Detail

#### retryConfig

    public void retryConfig(RetryConfig retryConfig)

#### useDatabase

    public void useDatabase(@NonNull
                            @NonNull java.lang.String dbName)
                     throws java.lang.InterruptedException

use Database

Parameters:
  `dbName` - databaseName
Throws:
  `java.lang.InterruptedException`

#### createDatabase

    public void createDatabase(CreateDatabaseReq request)

Creates a database in Milvus.

Parameters:
  `request` - create database request

#### dropDatabase

    public void dropDatabase(DropDatabaseReq request)

Drops a database. Note that this method drops all data in the database.

Parameters:
  `request` - drop database request

#### listDatabases

    public ListDatabasesResp listDatabases()

List all databases.

Returns:
  List of String database names

#### alterDatabase

    public void alterDatabase(AlterDatabaseReq request)

Alter database with key value pair. (Available from Milvus v2.4.4)

Parameters:
  `request` - alter database request

#### describeDatabase

    public DescribeDatabaseResp describeDatabase(DescribeDatabaseReq request)

Show detail of database base, such as replica number and resource groups. (Available from Milvus v2.4.4)

Parameters:
  `request` - describe database request
Returns:
  DescribeDatabaseResp

#### createCollection

    public void createCollection(CreateCollectionReq request)

Creates a collection in Milvus.

Parameters:
  `request` - create collection request

#### createSchema

    public CreateCollectionReq.CollectionSchema createSchema()

Creates a collection schema.

Returns:
  CreateCollectionReq.CollectionSchema

#### listCollections

    public ListCollectionsResp listCollections()

list milvus collections

Returns:
  List of String collection names

#### dropCollection

    public void dropCollection(DropCollectionReq request)

Drops a collection in Milvus.

Parameters:
  `request` - drop collection request

#### alterCollection

    public void alterCollection(AlterCollectionReq request)

Alter a collection in Milvus.

Parameters:
  `request` - alter collection request

#### hasCollection

    public java.lang.Boolean hasCollection(HasCollectionReq request)

Checks whether a collection exists in Milvus.

Parameters:
  `request` - has collection request
Returns:
  Boolean

#### describeCollection

    public DescribeCollectionResp describeCollection(DescribeCollectionReq request)

Gets the collection info in Milvus.

Parameters:
  `request` - describe collection request
Returns:
  DescribeCollectionResp

#### getCollectionStats

    public GetCollectionStatsResp getCollectionStats(GetCollectionStatsReq request)

get collection stats for a collection in Milvus.

Parameters:
  `request` - get collection stats request
Returns:
  GetCollectionStatsResp

#### renameCollection

    public void renameCollection(RenameCollectionReq request)

rename collection in a collection in Milvus.

Parameters:
  `request` - rename collection request

#### loadCollection

    public void loadCollection(LoadCollectionReq request)

Loads a collection into memory in Milvus.

Parameters:
  `request` - load collection request

#### releaseCollection

    public void releaseCollection(ReleaseCollectionReq request)

Releases a collection from memory in Milvus.

Parameters:
  `request` - release collection request

#### getLoadState

    public java.lang.Boolean getLoadState(GetLoadStateReq request)

Checks whether a collection is loaded in Milvus.

Parameters:
  `request` - get load state request
Returns:
  Boolean

#### createIndex

    public void createIndex(CreateIndexReq request)

Creates an index for a specified field in a collection in Milvus.

Parameters:
  `request` - create index request

#### dropIndex

    public void dropIndex(DropIndexReq request)

Drops an index for a specified field in a collection in Milvus.

Parameters:
  `request` - drop index request

#### alterIndex

    public void alterIndex(AlterIndexReq request)

Alter an index in Milvus.

Parameters:
  `request` - alter index request

#### describeIndex

    public DescribeIndexResp describeIndex(DescribeIndexReq request)

Checks whether an index exists for a specified field in a collection in Milvus.

Parameters:
  `request` - describe index request
Returns:
  DescribeIndexResp

#### listIndexes

    public java.util.List<java.lang.String> listIndexes(ListIndexesReq request)

Lists all indexes in a collection in Milvus.

Parameters:
  `request` - list indexes request
Returns:
  List of String names of the indexes

#### insert

    public InsertResp insert(InsertReq request)

Inserts vectors into a collection in Milvus.

Parameters:
  `request` - insert request
Returns:
  InsertResp

#### upsert

    public UpsertResp upsert(UpsertReq request)

Upsert vectors into a collection in Milvus.

Parameters:
  `request` - upsert request
Returns:
  UpsertResp

#### delete

    public DeleteResp delete(DeleteReq request)

Deletes vectors in a collection in Milvus.

Parameters:
  `request` - delete request
Returns:
  DeleteResp

#### get

    public GetResp get(GetReq request)

Gets vectors in a collection in Milvus.

Parameters:
  `request` - get request
Returns:
  GetResp

#### query

    public QueryResp query(QueryReq request)

Queries vectors in a collection in Milvus.

Parameters:
  `request` - query request
Returns:
  QueryResp

#### search

    public SearchResp search(SearchReq request)

Searches vectors in a collection in Milvus.

Parameters:
  `request` - search request
Returns:
  SearchResp

#### hybridSearch

    public SearchResp hybridSearch(HybridSearchReq request)

Conducts multi vector similarity search with a ranker for rearrangement.

Parameters:
  `request` - search request
Returns:
  SearchResp

#### queryIterator

    public QueryIterator queryIterator(QueryIteratorReq request)

Get queryIterator based on scalar field(s) filtered by boolean expression. Note that the order of the returned entities cannot be guaranteed.

Parameters:
  `request` - `QueryIteratorReq`
Returns:
  {status:result code,data: QueryIterator}

#### searchIterator

    public SearchIterator searchIterator(SearchIteratorReq request)

Get searchIterator based on a vector field. Use expression to do filtering before search.

Parameters:
  `request` - `SearchIteratorReq`
Returns:
  {status:result code, data: SearchIterator}

#### createPartition

    public void createPartition(CreatePartitionReq request)

Creates a partition in a collection in Milvus.

Parameters:
  `request` - create partition request

#### dropPartition

    public void dropPartition(DropPartitionReq request)

Drops a partition in a collection in Milvus.

Parameters:
  `request` - drop partition request

#### hasPartition

    public java.lang.Boolean hasPartition(HasPartitionReq request)

Checks whether a partition exists in a collection in Milvus.

Parameters:
  `request` - has partition request
Returns:
  Boolean

#### listPartitions

    public java.util.List<java.lang.String> listPartitions(ListPartitionsReq request)

Lists all partitions in a collection in Milvus.

Parameters:
  `request` - list partitions request
Returns:
  List of String partition names

#### loadPartitions

    public void loadPartitions(LoadPartitionsReq request)

Loads partitions in a collection in Milvus.

Parameters:
  `request` - load partitions request

#### releasePartitions

    public void releasePartitions(ReleasePartitionsReq request)

Releases partitions in a collection in Milvus.

Parameters:
  `request` - release partitions request

#### listUsers

    public java.util.List<java.lang.String> listUsers()

list users

Returns:
  List of String usernames

#### describeUser

    public DescribeUserResp describeUser(DescribeUserReq request)

describe user

Parameters:
  `request` - describe user request
Returns:
  DescribeUserResp

#### createUser

    public void createUser(CreateUserReq request)

create user

Parameters:
  `request` - create user request

#### updatePassword

    public void updatePassword(UpdatePasswordReq request)

change password

Parameters:
  `request` - change password request

#### dropUser

    public void dropUser(DropUserReq request)

drop user

Parameters:
  `request` - drop user request

#### listRoles

    public java.util.List<java.lang.String> listRoles()

list roles

Returns:
  List of String role names

#### describeRole

    public DescribeRoleResp describeRole(DescribeRoleReq request)

describe role

Parameters:
  `request` - describe role request
Returns:
  DescribeRoleResp

#### createRole

    public void createRole(CreateRoleReq request)

create role

Parameters:
  `request` - create role request

#### dropRole

    public void dropRole(DropRoleReq request)

drop role

Parameters:
  `request` - drop role request

#### grantPrivilege

    public void grantPrivilege(GrantPrivilegeReq request)

grant privilege

Parameters:
  `request` - grant privilege request

#### revokePrivilege

    public void revokePrivilege(RevokePrivilegeReq request)

revoke privilege

Parameters:
  `request` - revoke privilege request

#### grantRole

    public void grantRole(GrantRoleReq request)

grant role

Parameters:
  `request` - grant role request

#### revokeRole

    public void revokeRole(RevokeRoleReq request)

revoke role

Parameters:
  `request` - revoke role request

#### createAlias

    public void createAlias(CreateAliasReq request)

create aliases

Parameters:
  `request` - create alias request

#### dropAlias

    public void dropAlias(DropAliasReq request)

drop aliases

Parameters:
  `request` - drop alias request

#### alterAlias

    public void alterAlias(AlterAliasReq request)

alter aliases

Parameters:
  `request` - alter alias request

#### listAliases

    public ListAliasResp listAliases(ListAliasesReq request)

list aliases

Parameters:
  `request` - list aliases request
Returns:
  List of String alias names

#### describeAlias

    public DescribeAliasResp describeAlias(DescribeAliasReq request)

describe aliases

Parameters:
  `request` - describe alias request
Returns:
  DescribeAliasResp

#### getServerVersion

    public java.lang.String getServerVersion()

Get server version

Returns:
  String

#### close

    public void close(long maxWaitSeconds)
               throws java.lang.InterruptedException

Disconnects from a Milvus server with configurable timeout

Parameters:
  `maxWaitSeconds` - max wait seconds
Throws:
  `java.lang.InterruptedException` - throws InterruptedException if the client failed to close connection

#### close

    public void close()

Disconnects from a Milvus server with timeout of 1 second

#### clientIsReady

    public boolean clientIsReady()