import { FloatVector } from '..'; import type { ExportSnapshotState, Properties, RefreshExternalCollectionState, RestoreSnapshotState } from './Collection'; import type { FieldPartialUpdateOpName } from './Insert'; import type { KeyValuePair } from './Common'; import type { SegmentLevel } from '../const'; import type { SparseVectorCSR, SparseVectorDic } from './DataTypes'; import type { AggregationDirection, AggregationMetricOp } from './SearchAggregation'; type Fetch = (input: any, init?: any) => Promise; export type Constructor = 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 { 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; } export interface HttpCollectionTypeSchema { leafType?: string; arrayElement?: HttpCollectionTypeSchema; typeParams?: Record; nullable?: boolean; } export interface HttpCollectionFieldSchema { fieldName: string; dataType: string; description?: string; elementDataType?: string; elementNullable?: boolean; typeSchema?: HttpCollectionTypeSchema; fields?: HttpCollectionFieldSchema[]; nullable?: boolean; defaultValue?: string | number | boolean | null; isPrimary?: boolean; isPartitionKey?: boolean; isClusteringKey?: boolean; externalField?: string; typeParams?: Record; elementTypeParams?: { max_length?: number; dim?: number; max_capacity?: number; [key: string]: unknown; }; } export interface HttpCollectionAddFieldReq extends HttpBaseReq { schema: HttpCollectionFieldSchema; } export interface HttpCollectionAddFieldResponse extends HttpBaseResponse { } export interface HttpCollectionAddStructFieldReq extends HttpBaseReq { schema: HttpCollectionFieldSchema & { fields: HttpCollectionFieldSchema[]; } & ({ dataType: 'ArrayOfStruct'; } | { dataType: 'Array'; elementDataType: 'Struct'; }); } export type HttpCollectionDropFieldReq = HttpBaseReq & ({ fieldName: string; fieldId?: never; } | { fieldName?: never; fieldId: number; }); export interface HttpCollectionFunction { name: string; type: string; description?: string; inputFieldNames: string[]; outputFieldNames: string[]; params?: Record; } export interface HttpCollectionFunctionReq extends HttpBaseReq { functionName: string; } export interface HttpCollectionAlterFunctionReq extends HttpCollectionFunctionReq { function: HttpCollectionFunction; } export interface HttpCollectionAddFunctionFieldReq extends HttpBaseReq { function: HttpCollectionFunction; outputField: HttpCollectionFieldSchema; indexParams?: { fieldName: string; indexName?: string; metricType?: string; indexType?: string; params?: Record; }; } type CollectionProperties = Record; 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[]; }> { } export interface HttpDatabaseAlterPropertiesReq { dbName: string; properties: Record; } export interface HttpDatabaseAlterPropertiesResponse extends HttpBaseResponse { } export interface HttpDatabaseDropPropertiesReq { dbName: string; propertyKeys: string[]; } export interface HttpDatabaseDropPropertiesResponse extends HttpBaseResponse { } export interface HttpCollectionListReq extends Omit { } 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 { } 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[]; } export interface HttpVectorUpsertReq extends HttpVectorInsertReq { partitionName?: string; partialUpdate?: boolean; fieldOps?: { fieldName: string; op: FieldPartialUpdateOpName; /** Required for PATH_REPLACE (Milvus 3.0.6+). */ path?: string; }[]; } 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[]; } type HttpExpressionScalar = boolean | number | string; type HttpExpressionArray = readonly (HttpExpressionScalar | HttpExpressionArray | Record)[]; /** JSON values used to fill placeholders in a REST filter. */ export type HttpExpressionParams = Record; export interface HttpVectorDeleteReq extends HttpBaseReq { filter: string; exprParams?: HttpExpressionParams; partitionName?: string; } export interface HttpVectorQueryReq extends HttpBaseReq { outputFields: string[]; filter?: string; exprParams?: HttpExpressionParams; /** Group by these scalar fields when outputFields contains aggregations. */ groupByFields?: string[]; /** Scalar sort keys in fieldName or fieldName:asc/desc form. */ orderByFields?: string[]; limit?: number; offset?: number; partitionNames?: string[]; consistencyLevel?: string; } type QueryResult = Record[]; export interface HttpVectorQueryResponse extends HttpBaseResponse { } /** JSON inputs for dense, sparse, text, or embedding-list search. */ export type HttpSearchDatum = FloatVector | FloatVector[] | SparseVectorDic | SparseVectorCSR | string | string[]; type HttpFunctionParam = HttpExpressionScalar | readonly HttpFunctionParam[] | { [key: string]: HttpFunctionParam; }; type HttpFunctionChainArg = { column: string; literal?: never; } | { column?: never; literal: HttpFunctionParam; }; export interface HttpFunctionChainOp { op: string; expr?: { name: string; args?: HttpFunctionChainArg[]; params?: Record; }; inputs?: string[]; outputs?: string[]; params?: Record; } export interface HttpFunctionChain { name?: string; stage: 'FunctionChainStageIngestion' | 'FunctionChainStagePreProcess' | 'FunctionChainStageL0Rerank' | 'FunctionChainStageL1Rerank' | 'FunctionChainStageL2Rerank' | 'FunctionChainStagePostProcess' | 'FunctionChainStageQueryScan'; ops: HttpFunctionChainOp[]; } export interface HttpFunctionScore { functions: HttpCollectionFunction[]; params?: Record; } interface HttpSearchGrouping { groupingField?: string; groupSize?: number; strictGroupSize?: boolean; } export interface HttpVectorSearchReq extends Omit, HttpSearchGrouping { data: HttpSearchDatum[]; ids?: never; annsField?: string; searchParams?: Record; functionScore?: HttpFunctionScore; functionChains?: HttpFunctionChain[]; searchAggregation?: never; } export interface HttpVectorSearchByIdsReq extends Omit { data?: never; /** Pass decimal strings for int64 primary keys beyond the safe integer range. */ ids: (number | string)[]; } interface HttpVectorHybridSearchParams { data: HttpSearchDatum[]; limit: number; filter?: string; exprParams?: HttpExpressionParams; outputFields?: string[]; offset?: number; annsField?: string; ignoreGrowing?: boolean; metricType?: string; params?: Record; functionChains?: HttpFunctionChain[]; } export interface HttpVectorHybridSearchReq extends HttpBaseReq, HttpSearchGrouping { search: HttpVectorHybridSearchParams[]; rerank?: Record; partitionNames?: string[]; outputFields?: string[]; limit?: number; offset?: number; consistencyLevel?: string; functionScore?: HttpFunctionScore; functionChains?: HttpFunctionChain[]; } export interface HttpSearchAggregation { fields: string[]; size: number; searchSize?: number; metrics?: Record; order?: { key: string; direction: AggregationDirection; }[]; topHits?: { size: number; sort?: { fieldName: string; direction: AggregationDirection; }[]; }; subAggregation?: HttpSearchAggregation; } export interface HttpVectorSearchAggregationReq extends Omit { searchAggregation: HttpSearchAggregation; } type HttpSearchAggregationValue = string | number | boolean | null; export interface HttpSearchAggregationBucket { key: { fieldName?: string; fieldId?: string | number; value?: HttpSearchAggregationValue; }[]; count: string | number; metrics: Record; hits: (Record & { distance?: number; })[]; subGroups: HttpSearchAggregationBucket[]; } interface HttpSearchMetrics { cost?: number; recalls?: number[]; scanned_remote_bytes?: number; scanned_total_bytes?: number; cache_hit_ratio?: number; } export interface HttpVectorSearchAggregationResponse extends HttpBaseResponse<{ buckets: HttpSearchAggregationBucket[]; }[]>, HttpSearchMetrics { /** The number of buckets for each query vector, when returned by Milvus. */ aggTopks?: number[]; } type QueryResultWithDistance = { distance: number | string; } & QueryResult; export interface HttpVectorSearchResponse extends HttpVectorQueryResponse, HttpSearchMetrics { 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 HttpCreateRoleReq extends HttpRoleBaseReq { description?: string; } export interface HttpAlterRoleReq extends HttpRoleBaseReq { description: string; } export interface HttpDescribeRoleReq extends HttpRoleBaseReq { dbName?: string; } export interface HttpRolePrivilegeV2Req extends HttpDescribeRoleReq { collectionName: string; privilege: string; } export interface HttpPrivilegeGroupReq { privilegeGroupName: string; } export interface HttpOperatePrivilegeGroupReq extends HttpPrivilegeGroupReq { privileges: string[]; } export interface HttpPrivilegeGroupInfo extends HttpPrivilegeGroupReq { /** Comma-separated privilege names returned by Milvus. */ privileges: string; } export interface HttpRolePrivilegeReq extends HttpRoleBaseReq { objectType: string; objectName: string; privilege: string; } export interface HttpRoleDescribeResponse extends HttpBaseResponse<(HttpRolePrivilegeReq & { dbName?: string; grantor?: string; })[]> { description?: string; } export interface HttpIndexCreateReq extends HttpBaseReq { indexParams: CollectionIndexParam[]; } export interface HttpIndexBaseReq extends HttpBaseReq { indexName: string; } export interface HttpIndexAlterPropertiesReq extends HttpIndexBaseReq { properties: Record; } 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 { } export type HttpAliasBaseReq = Pick; 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> { } export interface HttpAliasDropReq extends Partial { 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[][]; partitionName?: string; options?: { timeout?: string; /** Set to 'false' for manual commit. Verified on Milvus 3.0.6. */ auto_commit?: 'true' | 'false'; [key: string]: string | undefined; }; } export interface HttpImportCreateResponse extends HttpBaseResponse<{ jobId: string; }> { } export interface HttpImportJobReq extends Pick, HttpImportProjectRegionReq { jobId: string; } export interface HttpImportProgressReq extends HttpImportJobReq { } 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 interface HttpSnapshotReq extends HttpBaseReq { snapshotName: string; } export interface HttpCreateSnapshotReq extends HttpSnapshotReq { description?: string; compactionProtectionSeconds?: number; } export interface HttpSnapshotSummary { name: string; description: string; createTs: string; createUtcTs: string; } export interface HttpListSnapshotsResponse extends HttpBaseResponse { snapshotSummaries?: HttpSnapshotSummary[]; } export interface HttpDescribeSnapshotResponse extends HttpBaseResponse<{ snapshotName: string; collectionName: string; description: string; partitionNames: string[] | null; createTs: string; s3Location: string; }> { } export interface HttpRestoreSnapshotReq { snapshotName: string; sourceCollectionName: string; targetCollectionName: string; sourceDbName?: string; targetDbName?: string; } export interface HttpExportSnapshotReq extends HttpSnapshotReq { targetS3Path: string; externalSpec?: string; } export interface HttpRestoreExternalSnapshotReq { targetCollectionName: string; snapshotMetadataURI: string; dbName?: string; externalSpec?: string; } export interface HttpSnapshotJobReq { jobId: string; } export interface HttpSnapshotJobResponse extends HttpBaseResponse<{ jobId: string; }> { } interface HttpSnapshotJobInfo { jobId: string; snapshotName: string; dbName: string; collectionName: string; progress: number; reason: string; startTime: string; timeCost: string; } export interface HttpRestoreSnapshotJobInfo extends HttpSnapshotJobInfo { state: keyof typeof RestoreSnapshotState; } export interface HttpExportSnapshotJobInfo extends HttpSnapshotJobInfo { state: keyof typeof ExportSnapshotState; totalFiles: string; copiedFiles: string; totalBytes: string; snapshotMetadataURI: string; } export interface HttpPinSnapshotDataReq extends HttpSnapshotReq { ttlSeconds?: number; } export interface HttpRefreshExternalCollectionReq extends HttpBaseReq { externalSource?: string; externalSpec?: string; } export interface HttpRefreshExternalCollectionJobInfo { jobId: string; collectionName: string; state: keyof typeof RefreshExternalCollectionState; progress: number; externalSource: string; externalSpec: string; startTime: string; endTime: string; reason?: string; } export interface HttpResourceGroupReq { name: string; } export interface HttpResourceGroupConfig { requests: { node_num: number; }; limits: { node_num: number; }; transfer_from?: { resource_group: string; }[]; transfer_to?: { resource_group: string; }[]; node_filter?: { node_labels: Record; }; } export interface HttpCreateResourceGroupReq extends HttpResourceGroupReq { config?: HttpResourceGroupConfig; } export interface HttpUpdateResourceGroupsReq { resource_groups: Record; } export interface HttpTransferReplicaReq { sourceRgName: string; targetRgName: string; collectionName: string; replicaNum: number; } export interface HttpResourceGroupInfo { name: string; capacity?: number; num_available_node?: number; num_loaded_replica?: Record; num_outgoing_node?: Record; num_incoming_node?: Record; config?: { requests?: { node_num?: number; }; limits?: { node_num?: number; }; transfer_from?: { resource_group: string; }[]; transfer_to?: { resource_group: string; }[]; node_filter?: { node_labels?: KeyValuePair[]; }; }; nodes?: { node_id?: string; address?: string; hostname?: string; }[]; } export interface HttpDescribeResourceGroupResponse { resource_group?: HttpResourceGroupInfo; code?: number; message?: string; } export interface HttpFileResourceNameReq { name: string; } export interface HttpAddFileResourceReq extends HttpFileResourceNameReq { /** A path to an object in the Milvus server's storage. */ path: string; } export interface HttpRunAnalyzerReq { text: string[]; /** Analyzer settings or their JSON representation. */ analyzerParams?: Record | string; withDetail?: boolean; withHash?: boolean; dbName?: string; collectionName?: string; fieldName?: string; analyzerNames?: string[]; } export interface HttpAnalyzerToken { token: string; startOffset?: number; endOffset?: number; position?: number; positionLength?: number; hash?: number; } export interface HttpRunAnalyzerResult { results: { tokens: HttpAnalyzerToken[]; }[]; } export interface HttpGetSegmentsInfoReq { dbName?: string; collectionID?: string | number; segmentIDs: (string | number)[]; } export interface HttpSegmentLogInfo { fieldID: string; logIDs: string[] | null; } export interface HttpSegmentInfo { segmentID: string; collectionID: string; partitionID: string; vChannel: string; numRows: string; /** Numeric protobuf segment state returned by REST. */ state: number; level: SegmentLevel; isSorted: boolean; insertLogs: HttpSegmentLogInfo[]; deltaLogs: HttpSegmentLogInfo[]; statsLogs: HttpSegmentLogInfo[]; } export interface HttpGetSegmentsInfoResult { segmentInfos: HttpSegmentInfo[]; } export {};