@zilliz/milvus2-sdk-node
Version:
Official Node.js SDK for [Milvus](https://github.com/milvus-io/milvus) vector database. Provides gRPC and HTTP clients for vector similarity search, metadata filtering, and full collection/index/user management.
413 lines (412 loc) • 11.6 kB
TypeScript
import { FloatVector } from '..';
import type { Properties } from './Collection';
type Fetch = (input: any, init?: any) => Promise<any>;
export type Constructor<T = {}> = new (...args: any[]) => T;
export type FetchOptions = {
abortController: AbortController;
timeout: number;
};
type HttpClientConfigBase = {
database?: string;
token?: string;
username?: string;
password?: string;
timeout?: number;
fetch?: Fetch;
acceptInt64?: boolean;
};
type HttpClientConfigAddress = HttpClientConfigBase & {
endpoint: string;
baseURL?: string;
};
type HttpClientConfigBaseURL = HttpClientConfigBase & {
endpoint?: string;
baseURL: string;
};
export type HttpClientConfig = HttpClientConfigAddress | HttpClientConfigBaseURL;
export interface HttpBaseReq {
dbName?: string;
collectionName: string;
}
export interface HttpBaseResponse<T = {}> {
code: number;
data: T;
message?: string;
}
type CollectionIndexParam = {
metricType: string;
fieldName: string;
indexName: string;
params?: {
index_type: string;
nlist?: number;
M?: string;
efConstruction?: string;
};
};
type CollectionCreateParams = {
max_length?: number;
enableDynamicField?: boolean;
shardsNum?: number;
consistencyLevel?: string;
partitionsNum?: number;
ttlSeconds?: number;
};
type CollectionCreateField = {
fieldName: string;
dataType: string;
elementDataType?: string;
isPrimary?: boolean;
isPartitionKey?: boolean;
elementTypeParams?: {
max_length?: number;
dim?: number;
max_capacity?: number;
};
};
type CollectionCreateSchema = {
autoID?: boolean;
enabledDynamicField?: boolean;
fields: CollectionCreateField[];
};
export interface HttpCollectionCreateReq extends HttpBaseReq {
dimension?: number;
metricType?: string;
idType?: string;
autoID?: boolean;
primaryFieldName?: string;
vectorFieldName?: string;
schema?: CollectionCreateSchema;
indexParams?: CollectionIndexParam[];
params?: CollectionCreateParams;
}
type CollectionAddFieldSchema = {
fieldName: string;
dataType: string;
elementDataType?: string;
nullable?: boolean;
defaultValue?: string | number | boolean | null;
isPrimary?: boolean;
isPartitionKey?: boolean;
elementTypeParams?: {
max_length?: number;
dim?: number;
max_capacity?: number;
};
};
export interface HttpCollectionAddFieldReq extends HttpBaseReq {
schema: CollectionAddFieldSchema;
}
export interface HttpCollectionAddFieldResponse extends HttpBaseResponse {
}
type CollectionProperties = Record<string, string | number | boolean>;
export interface HttpCollectionAlterPropertiesReq extends HttpBaseReq {
properties: CollectionProperties;
}
export interface HttpCollectionAlterPropertiesResponse extends HttpBaseResponse {
}
type CollectionFieldParams = {
max_length?: number;
max_capacity?: number;
mmap_enabled?: boolean;
};
export interface HttpCollectionAlterFieldPropertiesReq extends HttpBaseReq {
fieldName: string;
fieldParams: CollectionFieldParams;
}
export interface HttpCollectionAlterFieldPropertiesResponse extends HttpBaseResponse {
}
export interface HttpCollectionDropPropertiesReq extends HttpBaseReq {
propertyKeys: string[];
}
export interface HttpCollectionDropPropertiesResponse extends HttpBaseResponse {
}
export interface HttpDatabaseCreateReq {
dbName: string;
properties?: Properties;
}
export interface HttpDatabaseDropReq {
dbName: string;
}
export interface HttpDatabaseDescribeReq {
dbName: string;
}
export interface HttpDatabaseDescribeResponse extends HttpBaseResponse<{
dbName: string;
dbId: number;
createdTime: string;
properties: Record<string, string | number | boolean>[];
}> {
}
export interface HttpDatabaseAlterPropertiesReq {
dbName: string;
properties: Record<string, string | number | boolean>;
}
export interface HttpDatabaseAlterPropertiesResponse extends HttpBaseResponse {
}
export interface HttpDatabaseDropPropertiesReq {
dbName: string;
propertyKeys: string[];
}
export interface HttpDatabaseDropPropertiesResponse extends HttpBaseResponse {
}
export interface HttpCollectionListReq extends Omit<HttpBaseReq, 'collectionName'> {
}
type Field = {
autoId?: boolean;
description: string;
primaryKey?: boolean;
type: string;
};
type Index = {
fieldName: string;
indexName: string;
metricType: string;
};
export interface HttpCollectionDescribeResponse extends HttpBaseResponse<{
collectionName: string;
description: string;
fields: Field[];
indexes: Index[];
load: string;
shardsNum: number;
enableDynamicField: boolean;
}> {
}
export interface HttpCollectionListResponse extends HttpBaseResponse<string[]> {
}
export interface HttpCollectionHasResponse extends HttpBaseResponse<{
has: boolean;
}> {
}
export interface HttpCollectionRenameReq extends HttpBaseReq {
newCollectionName: string;
newDbName?: string;
}
export interface HttpCollectionStatisticsResponse extends HttpBaseResponse<{
rowCount: number;
}> {
}
export interface HttpCollectionFlushResponse extends HttpBaseResponse {
}
export interface HttpCollectionCompactReq extends HttpBaseReq {
}
export interface HttpCollectionCompactResponse extends HttpBaseResponse<{
compactionID: number;
}> {
}
export interface HttpCollectionGetCompactionStateReq extends HttpBaseReq {
compactionID: number;
}
export interface HttpCollectionGetCompactionStateResponse extends HttpBaseResponse<{
state: number;
executingPlan: number;
timeoutPlan: number;
completedPlan: number;
}> {
}
export interface HttpCollectionRefreshLoadReq extends HttpBaseReq {
}
export interface HttpCollectionLoadStateReq extends HttpBaseReq {
partitionNames?: string;
}
export interface HttpCollectionLoadStateResponse extends HttpBaseResponse<{
loadProgress: number;
loadState: string;
}> {
}
export interface HttpVectorInsertReq extends HttpBaseReq {
data: Record<string, any>[];
}
export interface HttpVectorInsertResponse extends HttpBaseResponse<{
insertCount: number;
insertIds: number | string[];
}> {
}
export interface HttpVectorUpsertResponse extends HttpBaseResponse<{
upsertCount: number;
upsertIds: number | string[];
}> {
}
export interface HttpVectorGetReq extends HttpBaseReq {
id: number | number[] | string | string[];
outputFields: string[];
}
export interface HttpVectorDeleteReq extends HttpBaseReq {
filter: string;
partitionName?: string;
}
export interface HttpVectorQueryReq extends HttpBaseReq {
outputFields: string[];
filter?: string;
limit?: number;
offset?: number;
partitionNames?: string[];
consistencyLevel?: string;
}
type QueryResult = Record<string, any>[];
export interface HttpVectorQueryResponse extends HttpBaseResponse<QueryResult> {
}
export interface HttpVectorSearchReq extends HttpVectorQueryReq {
data: FloatVector[];
annsField?: string;
groupingField?: string;
searchParams?: Record<string, any>;
}
interface HttpVectorHybridSearchParams {
data: FloatVector[];
limit: number;
filter?: string;
outputFields?: string[];
offset?: number;
annsField?: string;
ignoreGrowing?: boolean;
metricType?: string;
params?: Record<string, string | number>;
}
export interface HttpVectorHybridSearchReq extends HttpBaseReq {
search: HttpVectorHybridSearchParams[];
rerank: Record<string, any>;
partitionNames?: string[];
outputFields?: string[];
limit?: number;
}
type QueryResultWithDistance = {
distance: number | string;
} & QueryResult;
export interface HttpVectorSearchResponse extends HttpVectorQueryResponse {
data: QueryResultWithDistance | QueryResultWithDistance[];
topks: number[];
}
export interface HttpPartitionBaseReq extends HttpBaseReq {
partitionName: string;
}
export interface HttpPartitionListReq extends HttpBaseReq {
partitionNames: string[];
}
export interface HttpPartitionHasResponse extends HttpBaseResponse<{
has: boolean;
}> {
}
export interface HttpPartitionStatisticsResponse extends HttpBaseResponse<{
rowCount: number;
}> {
}
export interface HttpUserBaseReq {
userName: string;
}
export interface HttpUserCreateReq extends HttpUserBaseReq {
password: string;
}
export interface HttpUserUpdatePasswordReq extends HttpUserCreateReq {
newPassword: string;
}
export interface HttpUserRoleReq extends HttpUserBaseReq {
roleName: string;
}
export interface HttpRoleBaseReq {
roleName: string;
}
export interface HttpRolePrivilegeReq extends HttpRoleBaseReq {
objectType: string;
objectName: string;
privilege: string;
}
export interface HttpRoleDescribeResponse extends HttpBaseResponse<HttpRolePrivilegeReq[]> {
}
export interface HttpIndexCreateReq extends HttpBaseReq {
indexParams: CollectionIndexParam[];
}
export interface HttpIndexBaseReq extends HttpBaseReq {
indexName: string;
}
export interface HttpIndexAlterPropertiesReq extends HttpIndexBaseReq {
properties: Record<string, string | number | boolean>;
}
export interface HttpIndexAlterPropertiesResponse extends HttpBaseResponse {
}
export interface HttpIndexDropPropertiesReq extends HttpIndexBaseReq {
propertyKeys: string[];
}
export interface HttpIndexDropPropertiesResponse extends HttpBaseResponse {
}
type IndexDescribeType = {
failReason: string;
fieldName: string;
indexName: string;
indexState: string;
indexType: string;
indexedRows: number;
metricType: string;
pendingRows: number;
totalRows: number;
};
export interface HttpIndexDescribeResponse extends HttpBaseResponse<IndexDescribeType[]> {
}
export type HttpAliasBaseReq = Pick<HttpBaseReq, 'dbName'>;
export interface HttpAliasCreateReq extends HttpBaseReq {
aliasName: string;
}
export type HttpAliasAlterReq = HttpAliasCreateReq;
export interface HttpAliasDescribeReq extends HttpAliasBaseReq {
aliasName: string;
}
export interface HttpAliasDescribeResponse extends HttpBaseResponse<{
aliasName: string;
} & Required<HttpBaseReq>> {
}
export interface HttpAliasDropReq extends Partial<HttpBaseReq> {
aliasName: string;
}
type ImportJobType = {
collectionName: string;
jobId: string;
progress: number;
state: string;
};
type ImportJobDetailType = {
completeTime: string;
fileName: string;
fileSize: number;
importedRows: number;
progress: number;
state: string;
totalRows: number;
};
export interface HttpImportListResponse extends HttpBaseResponse<{
records: ImportJobType[];
}> {
}
interface HttpImportProjectRegionReq {
projectId?: string;
regionId?: string;
}
export interface HttpImportListReq extends HttpBaseReq, HttpImportProjectRegionReq {
}
export interface HttpImportCreateReq extends HttpBaseReq, HttpImportProjectRegionReq {
files: string[][];
options?: {
timeout: string;
};
}
export interface HttpImportCreateResponse extends HttpBaseResponse<{
jobId: string;
}> {
}
export interface HttpImportProgressReq extends Pick<HttpBaseReq, 'dbName'>, HttpImportProjectRegionReq {
jobId: string;
}
export interface HttpImportProgressResponse extends HttpBaseResponse<{
jobId: string;
progress: number;
state: string;
totalRows?: number;
importedRows?: number;
fileSize?: number;
completeTime?: string;
collectionName?: string;
details?: ImportJobDetailType[];
reason?: string;
}> {
}
export {};