dto.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import {
  2. IsNotEmpty,
  3. IsString,
  4. IsBoolean,
  5. IsOptional,
  6. IsArray,
  7. ArrayNotEmpty,
  8. IsEnum,
  9. ArrayMinSize,
  10. IsObject,
  11. } from 'class-validator';
  12. import {
  13. FieldType,
  14. ShowCollectionsType,
  15. } from '@zilliz/milvus2-sdk-node/dist/milvus/types/Collection';
  16. import { DataType } from '@zilliz/milvus2-sdk-node/dist/milvus/types/Common';
  17. import { SearchParam } from '@zilliz/milvus2-sdk-node/dist/milvus/types';
  18. enum VectorTypes {
  19. Binary = DataType.BinaryVector,
  20. Float = DataType.FloatVector,
  21. }
  22. export class CreateCollectionDto {
  23. @IsString()
  24. readonly collection_name: string;
  25. @IsBoolean()
  26. @IsOptional()
  27. readonly autoID: boolean;
  28. @IsArray()
  29. @ArrayNotEmpty()
  30. readonly fields: FieldType[];
  31. }
  32. export class ShowCollectionsDto {
  33. @IsOptional()
  34. @IsEnum(ShowCollectionsType, { message: 'Type allow all->0 inmemory->1' })
  35. readonly type: ShowCollectionsType;
  36. }
  37. export class InsertDataDto {
  38. @IsOptional()
  39. readonly partition_names?: string[];
  40. @IsArray()
  41. readonly fields_data: any[];
  42. }
  43. export class ImportSampleDto {
  44. readonly collection_name?: string;
  45. readonly size: string;
  46. }
  47. export class GetReplicasDto {
  48. readonly collectionID: string;
  49. readonly with_shard_nodes?: boolean;
  50. }
  51. export class VectorSearchDto {
  52. @IsOptional()
  53. partition_names?: string[];
  54. @IsString()
  55. @IsOptional()
  56. expr?: string;
  57. @IsObject()
  58. search_params: SearchParam;
  59. @IsArray()
  60. @ArrayMinSize(1)
  61. vectors: number[][];
  62. @IsArray()
  63. @IsOptional()
  64. output_fields?: string[];
  65. @IsEnum(VectorTypes, {
  66. message: ({ value }) => `Wrong vector type, ${value}`,
  67. })
  68. vector_type: DataType.BinaryVector | DataType.FloatVector;
  69. }
  70. export class CreateAliasDto {
  71. @IsString()
  72. alias: string;
  73. }
  74. export class QueryDto {
  75. @IsString()
  76. readonly expr: string;
  77. @IsArray()
  78. @IsOptional()
  79. readonly partitions_names: string[];
  80. @IsArray()
  81. @IsOptional()
  82. readonly output_fields: string[];
  83. }