API Reference
Complete API reference for the Milvus Node.js SDK.
MilvusClient
Main client class for interacting with Milvus.
Constructor
new MilvusClient(config: ClientConfig | string, ssl?: boolean, username?: string, password?: string, channelOptions?: ChannelOptions)Static Properties
sdkInfo
Get SDK version information:
MilvusClient.sdkInfo
// Returns: { version: string, recommendMilvus: string }Collection Operations
createCollection
Create a new collection.
createCollection(data: CreateCollectionReq): Promise<ResStatus>Parameters:
collection_name: Collection namefields: Array of field schemasconsistency_level?: Consistency levelproperties?: Collection properties
hasCollection
Check if collection exists.
hasCollection(data: HasCollectionReq): Promise<BoolResponse>showCollections
List all collections.
showCollections(data?: ShowCollectionsReq): Promise<ShowCollectionsResponse>describeCollection
Get collection information.
describeCollection(data: DescribeCollectionReq): Promise<DescribeCollectionResponse>alterCollectionProperties
Modify collection properties.
alterCollectionProperties(data: AlterCollectionReq): Promise<ResStatus>dropCollection
Delete a collection.
dropCollection(data: DropCollectionReq): Promise<ResStatus>loadCollection
Load collection into memory.
loadCollection(data: LoadCollectionReq): Promise<ResStatus>loadCollectionSync
Load collection synchronously.
loadCollectionSync(data: LoadCollectionReq): Promise<ResStatus>releaseCollection
Release collection from memory.
releaseCollection(data: ReleaseLoadCollectionReq): Promise<ResStatus>truncateCollection
Clear all data from a collection while keeping the schema.
truncateCollection(data: DropCollectionReq): Promise<{ status: ResStatus }>Parameters:
collection_name: Collection name
batchDescribeCollections
Describe multiple collections in one call.
batchDescribeCollections(data: BatchDescribeCollectionReq): Promise<BatchDescribeCollectionResponse>Parameters:
collection_names: Array of collection names
renameCollection
Rename a collection.
renameCollection(data: RenameCollectionReq): Promise<ResStatus>Parameters:
collection_name: Current collection namenew_collection_name: New collection name
alterCollectionFieldProperties
Modify field properties of a collection.
alterCollectionFieldProperties(data: AlterCollectionFieldPropertiesReq): Promise<ResStatus>refreshLoad
Refresh a loaded collection to pick up schema changes.
refreshLoad(data: RefreshLoadReq): Promise<ResStatus>addCollectionFunction
Add a function to a collection.
addCollectionFunction(data: AddCollectionFunctionReq): Promise<ResStatus>Parameters:
collection_name: Collection namefunction: Function schema (name, type, input/output fields, params)
dropCollectionFunction
Remove a function from a collection.
dropCollectionFunction(data: DropCollectionFunctionReq): Promise<ResStatus>Data Operations
insert
Insert data into collection.
insert(data: InsertReq): Promise<MutationResult>Parameters:
collection_name: Collection namedata: Array of data objectspartition_name?: Partition name
upsert
Upsert data (insert or update).
upsert(data: UpsertReq): Promise<MutationResult>query
Query entities by filter.
query(data: QueryReq): Promise<QueryResults>Parameters:
collection_name: Collection nameexpr: Filter expressionoutput_fields: Fields to returnlimit?: Result limitoffset?: Result offset
search
Search similar vectors.
search(data: SearchReq): Promise<SearchResults>Parameters:
collection_name: Collection namedata: Array of search vectorslimit: Number of resultsexpr?: Filter expressionoutput_fields?: Fields to returnparams?: Search parameters
delete
Delete entities.
delete(data: DeleteReq): Promise<MutationResult>Parameters:
collection_name: Collection nameids?: Array of IDsfilter?: Filter expressionexpr?: Filter expression
count
Count entities matching filter.
count(data: CountReq): Promise<CountResult>hybridSearch
Hybrid search across multiple vector fields (alias for search with HybridSearchReq).
hybridSearch(data: HybridSearchReq): Promise<SearchResults>searchIterator
Search with iterator-based pagination.
searchIterator(data: SearchIteratorReq): Promise<AsyncIterable>queryIterator
Query with iterator-based pagination.
queryIterator(data: QueryIteratorReq): Promise<AsyncIterable>get
Get entities by primary key.
get(data: GetReq): Promise<QueryResults>Parameters:
collection_name: Collection nameids: Array of primary key valuesoutput_fields: Fields to return
flushAll
Flush all collections asynchronously.
flushAll(): Promise<FlushAllResponse>flushAllSync
Flush all collections synchronously (waits for completion).
flushAllSync(): Promise<GetFlushAllStateResponse>getFlushAllState
Get the state of a flush-all operation.
getFlushAllState(data: GetFlushAllStateReq): Promise<GetFlushAllStateResponse>compact
Compact a collection (brief entry — see Data Management for details).
compact(data: CompactReq): Promise<CompactionResponse>getCompactionState
Get compaction state (brief entry — see Data Management for details).
getCompactionState(data: GetCompactionStateReq): Promise<GetCompactionStateResponse>bulkInsert
Bulk insert data from files.
bulkInsert(data: BulkInsertReq): Promise<ImportResponse>getImportState
Get bulk import task state.
getImportState(data: GetImportStateReq): Promise<GetImportStateResponse>listImportTasks
List import tasks.
listImportTasks(data?: ListImportTasksReq): Promise<ListImportTasksResponse>Index Operations
createIndex
Create an index.
createIndex(data: CreateIndexReq): Promise<ResStatus>Parameters:
collection_name: Collection namefield_name: Field nameindex_type: Index typemetric_type: Metric typeparams?: Index parameters
describeIndex
Get index information.
describeIndex(data: DescribeIndexReq): Promise<DescribeIndexResponse>dropIndex
Delete an index.
dropIndex(data: DropIndexReq): Promise<ResStatus>getIndexState
Get index build state.
getIndexState(data: GetIndexStateReq): Promise<GetIndexStateResponse>listIndexes
List all indexes on a collection.
listIndexes(data: DescribeIndexReq): Promise<string[]>getIndexStatistics
Get index statistics.
getIndexStatistics(data: DescribeIndexReq): Promise<DescribeIndexResponse>alterIndexProperties
Modify index properties.
alterIndexProperties(data: AlterIndexReq): Promise<ResStatus>dropIndexProperties
Remove index properties.
dropIndexProperties(data: DropIndexPropertiesReq): Promise<ResStatus>Partition Operations
createPartition
Create a partition.
createPartition(data: CreatePartitionReq): Promise<ResStatus>listPartitions
List partitions.
listPartitions(data: ListPartitionsReq): Promise<ListPartitionsResponse>dropPartition
Delete a partition.
dropPartition(data: DropPartitionReq): Promise<ResStatus>Database Operations
createDatabase
Create a database.
createDatabase(data: CreateDatabaseRequest): Promise<ResStatus>listDatabases
List all databases.
listDatabases(data?: ListDatabasesRequest): Promise<ListDatabasesResponse>dropDatabase
Delete a database.
dropDatabase(data: DropDatabasesRequest): Promise<ResStatus>describeDatabase
Get database information.
describeDatabase(data: DescribeDatabaseRequest): Promise<DescribeDatabaseResponse>alterDatabaseProperties
Modify database properties.
alterDatabaseProperties(data: AlterDatabaseRequest): Promise<ResStatus>dropDatabaseProperties
Remove database properties.
dropDatabaseProperties(data: DropDatabasePropertiesRequest): Promise<ResStatus>User & Role Operations
createUser
Create a user.
createUser(data: CreateUserReq): Promise<ResStatus>updateUser
Update user password.
updateUser(data: UpdateUserReq): Promise<ResStatus>deleteUser
Delete a user.
deleteUser(data: DeleteUserReq): Promise<ResStatus>createRole
Create a role.
createRole(data: CreateRoleReq): Promise<ResStatus>grantPrivilege
Grant privilege to role.
grantPrivilege(data: OperateRolePrivilegeReq): Promise<ResStatus>System Operations
getVersion
Get server version.
getVersion(): Promise<GetVersionResponse>checkHealth
Check server health.
checkHealth(): Promise<CheckHealthResponse>runAnalyzer
Test text analyzer/tokenizer.
runAnalyzer(data: RunAnalyzerRequest): Promise<RunAnalyzerResponse>Parameters:
text: Array of text strings to analyzeanalyzer_params: Analyzer configuration (type, etc.)
getMetric
Get system metrics.
getMetric(data: GetMetricsRequest): Promise<GetMetricsResponse>Data Types
DataType Enum
enum DataType {
None = 0,
Bool = 1,
Int8 = 2,
Int16 = 3,
Int32 = 4,
Int64 = 5,
Float = 10,
Double = 11,
VarChar = 21,
Array = 22,
JSON = 23,
Geometry = 24,
Timestamptz = 26,
BinaryVector = 100,
FloatVector = 101,
Float16Vector = 102,
BFloat16Vector = 103,
SparseFloatVector = 104,
Int8Vector = 105,
Struct = 201,
}Error Codes
ErrorCode Enum
enum ErrorCode {
SUCCESS = 'Success',
IndexNotExist = 'IndexNotExist',
UnexpectedError = 'UnexpectedError',
EmptyCollection = 'EmptyCollection',
UpsertAutoIDTrue = 'UpsertAutoIDTrue',
CollectionNotExists = 'CollectionNotExists',
IllegalArgument = 'IllegalArgument',
RateLimit = 'RateLimit',
SchemaMismatch = 'SchemaMismatch',
}Response Types
ResStatus
interface ResStatus {
error_code: string;
reason?: string;
}MutationResult
interface MutationResult {
IDs: number[] | string[];
insert_cnt: number;
delete_cnt: number;
upsert_cnt: number;
timestamp: string;
status: ResStatus;
}QueryResults
interface QueryResults {
data: RowData[];
status: ResStatus;
}SearchResults
interface SearchResults {
results: SearchResult[];
status: ResStatus;
}Next Steps
- Explore Examples & Tutorials
- Check Best Practices
- Read Troubleshooting