123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- import {
- IsNotEmpty,
- IsString,
- IsBoolean,
- IsOptional,
- IsArray,
- ArrayNotEmpty,
- IsEnum,
- ArrayMinSize,
- IsObject,
- } from 'class-validator';
- import {
- FieldType,
- ShowCollectionsType,
- } from '@zilliz/milvus2-sdk-node/dist/milvus/types/Collection';
- import { DataType } from '@zilliz/milvus2-sdk-node/dist/milvus/types/Common';
- import { ApiProperty } from '@nestjs/swagger';
- import { SearchParam } from '@zilliz/milvus2-sdk-node/dist/milvus/types';
- enum VectorTypes {
- Binary = DataType.BinaryVector,
- Float = DataType.FloatVector,
- }
- export class CreateCollection {
- @ApiProperty({
- description: 'Milvus collection name',
- })
- @IsString()
- @IsNotEmpty({
- message: 'collection_name is empty',
- })
- readonly collection_name: string;
- @ApiProperty({
- description: 'Generate ID automatically by milvus',
- type: Boolean,
- })
- @IsBoolean()
- @IsOptional()
- readonly autoID: boolean;
- @ApiProperty({
- description: 'Field data type',
- })
- @IsArray()
- @ArrayNotEmpty()
- @IsNotEmpty({
- message: 'fields is empty',
- })
- readonly fields: FieldType[];
- }
- export class ShowCollections {
- @ApiProperty({
- description: 'Type allow all->0 inmemory->1',
- enum: ShowCollectionsType,
- })
- @IsOptional()
- @IsEnum(ShowCollectionsType, { message: 'Type allow all->0 inmemory->1' })
- readonly type: ShowCollectionsType;
- }
- export class InsertData {
- @ApiProperty({
- description: 'Partition in this collection',
- })
- @IsOptional()
- readonly partition_names: string[];
- @ApiProperty({
- description: 'The fields data in this collection',
- default: [{ vector: [1, 2, 3], a: 1, b: 2 }],
- })
- readonly fields_data: any[];
- }
- export class VectorSearch {
- @ApiProperty({
- description: 'Milvus collection name',
- })
- @IsString()
- @IsNotEmpty({
- message: 'collection_name is empty',
- })
- collection_name: string;
- @ApiProperty({
- description: 'Partition in this collection',
- })
- @IsOptional()
- partition_names?: string[];
- @ApiProperty({
- description: 'Non vector fields filter.',
- })
- @IsString()
- expr?: string;
- @ApiProperty({
- description: 'Vector search params',
- default: [{ key: 'metric_type', value: 'L2' }],
- })
- @IsObject()
- search_params: SearchParam;
- @ApiProperty({
- description: 'Searched vector value',
- default: [[1, 2, 3, 4]],
- })
- @IsArray()
- @ArrayMinSize(1)
- vectors: number[][];
- @ApiProperty({
- description:
- 'Define what non vector fields you want return in search results',
- default: ['a', 'b'],
- })
- @IsArray()
- @IsOptional()
- output_fields?: string[];
- @ApiProperty({
- description: 'Only support 101(binary) or 100(float)',
- enum: VectorTypes,
- })
- @IsEnum(VectorTypes, { message: 'Type allow all->0 inmemory->1' })
- vector_type: DataType.BinaryVector | DataType.FloatVector;
- }
|