dto.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. @IsNotEmpty({
  25. message: "collection_name is empty",
  26. })
  27. readonly collection_name: string;
  28. @IsBoolean()
  29. @IsOptional()
  30. readonly autoID: boolean;
  31. @IsArray()
  32. @ArrayNotEmpty()
  33. @IsNotEmpty({
  34. message: "fields is required",
  35. })
  36. readonly fields: FieldType[];
  37. }
  38. export class ShowCollectionsDto {
  39. @IsOptional()
  40. @IsEnum(ShowCollectionsType, { message: "Type allow all->0 inmemory->1" })
  41. readonly type: ShowCollectionsType;
  42. }
  43. export class InsertDataDto {
  44. @IsOptional()
  45. readonly partition_names?: string[];
  46. @IsNotEmpty({
  47. message: "fields_data is requried",
  48. })
  49. readonly fields_data: any[];
  50. }
  51. export class VectorSearchDto {
  52. @IsString()
  53. @IsNotEmpty({
  54. message: "collection_name is requried",
  55. })
  56. collection_name: string;
  57. @IsOptional()
  58. partition_names?: string[];
  59. @IsString()
  60. @IsOptional()
  61. expr?: string;
  62. @IsObject()
  63. @IsNotEmpty({
  64. message: "search_params is requried",
  65. })
  66. search_params: SearchParam;
  67. @IsArray()
  68. @ArrayMinSize(1)
  69. @IsNotEmpty({
  70. message: "vectors is requried",
  71. })
  72. vectors: number[][];
  73. @IsArray()
  74. @IsOptional()
  75. output_fields?: string[];
  76. @IsEnum(VectorTypes, { message: "Type allow all->0 inmemory->1" })
  77. @IsNotEmpty({
  78. message: "vector_type is requried",
  79. })
  80. vector_type: DataType.BinaryVector | DataType.FloatVector;
  81. }
  82. export class CreateAliasDto {
  83. @IsString()
  84. @IsNotEmpty({
  85. message: "alias is required",
  86. })
  87. alias: string;
  88. }