dto.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 VectorSearchDto {
  44. @IsOptional()
  45. partition_names?: string[];
  46. @IsString()
  47. @IsOptional()
  48. expr?: string;
  49. @IsObject()
  50. search_params: SearchParam;
  51. @IsArray()
  52. @ArrayMinSize(1)
  53. vectors: number[][];
  54. @IsArray()
  55. @IsOptional()
  56. output_fields?: string[];
  57. @IsEnum(VectorTypes, { message: "Type allow all->0 inmemory->1" })
  58. vector_type: DataType.BinaryVector | DataType.FloatVector;
  59. }
  60. export class CreateAliasDto {
  61. @IsString()
  62. alias: string;
  63. }
  64. export class QueryDto {
  65. @IsString()
  66. readonly expr: string;
  67. @IsArray()
  68. @IsOptional()
  69. readonly partitions_names: string[];
  70. @IsArray()
  71. @IsOptional()
  72. readonly output_fields: string[];
  73. }