Milvus.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. export const MILVUS_URL =
  2. ((window as any)._env_ && (window as any)._env_.MILVUS_URL) || '';
  3. export const MILVUS_DATABASE =
  4. ((window as any)._env_ && (window as any)._env_.DATABASE) || 'default';
  5. export const DYNAMIC_FIELD = `$meta`;
  6. export enum DataTypeEnum {
  7. Bool = 1,
  8. Int8 = 2,
  9. Int16 = 3,
  10. Int32 = 4,
  11. Int64 = 5,
  12. Float = 10,
  13. Double = 11,
  14. String = 20,
  15. VarChar = 21,
  16. JSON = 23,
  17. BinaryVector = 100,
  18. FloatVector = 101,
  19. Float16Vector = 102,
  20. SparseFloatVector = 104,
  21. BFloat16Vector = 103,
  22. Array = 22,
  23. }
  24. export const VectorTypes = [
  25. DataTypeEnum.BinaryVector,
  26. DataTypeEnum.FloatVector,
  27. DataTypeEnum.BFloat16Vector,
  28. DataTypeEnum.Float16Vector,
  29. DataTypeEnum.SparseFloatVector,
  30. ];
  31. export enum INDEX_TYPES_ENUM {
  32. AUTOINDEX = 'AUTOINDEX',
  33. IVF_FLAT = 'IVF_FLAT',
  34. IVF_PQ = 'IVF_PQ',
  35. IVF_SQ8 = 'IVF_SQ8',
  36. IVF_SQ8_HYBRID = 'IVF_SQ8_HYBRID',
  37. FLAT = 'FLAT',
  38. HNSW = 'HNSW',
  39. ANNOY = 'ANNOY',
  40. RNSG = 'RNSG',
  41. BIN_IVF_FLAT = 'BIN_IVF_FLAT',
  42. BIN_FLAT = 'BIN_FLAT',
  43. SORT = 'STL_SORT',
  44. MARISA_TRIE = 'Trie',
  45. // sparse
  46. SPARSE_INVERTED_INDEX = 'SPARSE_INVERTED_INDEX',
  47. SPARSE_WAND = 'SPARSE_WAND',
  48. // inverted
  49. INVERTED = 'INVERTED',
  50. }
  51. export enum METRIC_TYPES_VALUES {
  52. L2 = 'L2',
  53. IP = 'IP',
  54. COSINE = 'COSINE',
  55. HAMMING = 'HAMMING',
  56. JACCARD = 'JACCARD',
  57. TANIMOTO = 'TANIMOTO',
  58. SUBSTRUCTURE = 'SUBSTRUCTURE',
  59. SUPERSTRUCTURE = 'SUPERSTRUCTURE',
  60. }
  61. export const METRIC_TYPES = [
  62. {
  63. value: METRIC_TYPES_VALUES.L2,
  64. label: 'L2',
  65. },
  66. {
  67. value: METRIC_TYPES_VALUES.IP,
  68. label: 'IP',
  69. },
  70. {
  71. value: METRIC_TYPES_VALUES.COSINE,
  72. label: 'COSINE',
  73. },
  74. {
  75. value: METRIC_TYPES_VALUES.SUBSTRUCTURE,
  76. label: 'SUBSTRUCTURE',
  77. },
  78. {
  79. value: METRIC_TYPES_VALUES.SUPERSTRUCTURE,
  80. label: 'SUPERSTRUCTURE',
  81. },
  82. {
  83. value: METRIC_TYPES_VALUES.HAMMING,
  84. label: 'HAMMING',
  85. },
  86. {
  87. value: METRIC_TYPES_VALUES.JACCARD,
  88. label: 'JACCARD',
  89. },
  90. {
  91. value: METRIC_TYPES_VALUES.TANIMOTO,
  92. label: 'TANIMOTO',
  93. },
  94. ];
  95. export type MetricType =
  96. | 'L2'
  97. | 'IP'
  98. | 'COSINE'
  99. | 'HAMMING'
  100. | 'SUBSTRUCTURE'
  101. | 'SUPERSTRUCTURE'
  102. | 'JACCARD'
  103. | 'TANIMOTO';
  104. export type searchKeywordsType =
  105. | 'nprobe'
  106. | 'ef'
  107. | 'search_k'
  108. | 'search_length'
  109. | 'round_decimal'
  110. | 'level'
  111. | 'search_list'
  112. | 'radius'
  113. | 'range_filter'
  114. | 'drop_ratio_search'
  115. | 'filter'
  116. | 'itopk_size'
  117. | 'search_width'
  118. | 'min_iterations'
  119. | 'max_iterations'
  120. | 'team_size';
  121. export type indexConfigType = {
  122. [x: string]: {
  123. create: string[];
  124. search: searchKeywordsType[];
  125. };
  126. };
  127. // index
  128. const AUTOINDEX_CONFIG: indexConfigType = {
  129. AUTOINDEX: {
  130. create: [],
  131. search: ['level'],
  132. },
  133. };
  134. export const FLOAT_INDEX_CONFIG: indexConfigType = {
  135. HNSW: {
  136. create: ['M', 'efConstruction'],
  137. search: ['ef'],
  138. },
  139. IVF_FLAT: {
  140. create: ['nlist'],
  141. search: ['nprobe'],
  142. },
  143. IVF_PQ: {
  144. create: ['nlist', 'm', 'nbits'],
  145. search: ['nprobe'],
  146. },
  147. IVF_SQ8: {
  148. create: ['nlist'],
  149. search: ['nprobe'],
  150. },
  151. FLAT: {
  152. create: [],
  153. search: ['nprobe'],
  154. },
  155. SCANN: {
  156. create: ['nlist', 'with_raw_data'],
  157. search: ['nprobe'],
  158. },
  159. };
  160. export const DISK_INDEX_CONFIG: indexConfigType = {
  161. DISKANN: {
  162. create: [],
  163. search: ['search_list'],
  164. },
  165. };
  166. export const GPU_INDEX_CONFIG: indexConfigType = {
  167. GPU_CAGRA: {
  168. create: [
  169. 'intermediate_graph_degree',
  170. 'graph_degree',
  171. 'build_algo',
  172. 'cache_dataset_on_device',
  173. ],
  174. search: [
  175. 'itopk_size',
  176. 'search_width',
  177. 'min_iterations',
  178. 'max_iterations',
  179. 'team_size',
  180. ],
  181. },
  182. GPU_IVF_FLAT: {
  183. create: ['nlist'],
  184. search: ['nprobe'],
  185. },
  186. GPU_IVF_PQ: {
  187. create: ['nlist', 'm', 'nbits'],
  188. search: ['nprobe'],
  189. },
  190. GPU_BRUTE_FORCE: {
  191. create: [],
  192. search: [],
  193. },
  194. };
  195. export const BINARY_INDEX_CONFIG: indexConfigType = {
  196. BIN_FLAT: {
  197. create: [],
  198. search: [],
  199. },
  200. BIN_IVF_FLAT: {
  201. create: ['nlist'],
  202. search: ['nprobe'],
  203. },
  204. };
  205. export const SPARSE_INDEX_CONFIG: indexConfigType = {
  206. SPARSE_INVERTED_INDEX: {
  207. create: ['drop_ratio_build'],
  208. search: ['drop_ratio_search'],
  209. },
  210. SPARSE_WAND: {
  211. create: ['drop_ratio_build'],
  212. search: ['drop_ratio_search'],
  213. },
  214. };
  215. export const INDEX_CONFIG: indexConfigType = {
  216. ...AUTOINDEX_CONFIG,
  217. ...FLOAT_INDEX_CONFIG,
  218. ...BINARY_INDEX_CONFIG,
  219. ...SPARSE_INDEX_CONFIG,
  220. ...DISK_INDEX_CONFIG,
  221. ...GPU_INDEX_CONFIG,
  222. };
  223. export const COLLECTION_NAME_REGX = /^[0-9,a-z,A-Z$_]+$/;
  224. export const m_OPTIONS = [
  225. { label: '64', value: 64 },
  226. { label: '32', value: 32 },
  227. { label: '16', value: 16 },
  228. { label: '8', value: 8 },
  229. { label: '4', value: 4 },
  230. ];
  231. export const INDEX_OPTIONS_MAP = {
  232. ['AUTOINDEX']: [{ label: 'AUTOINDEX', value: INDEX_TYPES_ENUM.AUTOINDEX }],
  233. [DataTypeEnum.FloatVector]: Object.keys(FLOAT_INDEX_CONFIG).map(v => ({
  234. label: v,
  235. value: v,
  236. })),
  237. [DataTypeEnum.BinaryVector]: Object.keys(BINARY_INDEX_CONFIG).map(v => ({
  238. label: v,
  239. value: v,
  240. })),
  241. [DataTypeEnum.SparseFloatVector]: Object.keys(SPARSE_INDEX_CONFIG).map(v => ({
  242. label: v,
  243. value: v,
  244. })),
  245. [DataTypeEnum.VarChar]: [
  246. {
  247. label: 'INVERTED',
  248. value: INDEX_TYPES_ENUM.INVERTED,
  249. },
  250. {
  251. label: 'marisa-trie',
  252. value: INDEX_TYPES_ENUM.MARISA_TRIE,
  253. },
  254. ],
  255. ['DISK']: Object.keys(DISK_INDEX_CONFIG).map(v => ({
  256. label: v,
  257. value: v,
  258. })),
  259. ['GPU']: Object.keys(GPU_INDEX_CONFIG).map(v => ({
  260. label: v,
  261. value: v,
  262. })),
  263. };
  264. // search params default value map
  265. export const DEFAULT_SEARCH_PARAM_VALUE_MAP: {
  266. [key in searchKeywordsType]?: number;
  267. } = {
  268. // range: [top_k, 32768]
  269. ef: 250,
  270. // range: [1, nlist]
  271. nprobe: 1,
  272. // range: {-1} ∪ [top_k, n × n_trees]
  273. search_k: 250,
  274. // range: [10, 300]
  275. search_length: 10,
  276. level: 1,
  277. search_list: 150,
  278. };
  279. export const DEFAULT_NLIST_VALUE = 1024;
  280. export enum LOADING_STATE {
  281. LOADED = 'loaded',
  282. LOADING = 'loading',
  283. UNLOADED = 'unloaded',
  284. }
  285. export enum LOAD_STATE {
  286. LoadStateNotExist = 'LoadStateNotExist',
  287. LoadStateNotLoad = 'LoadStateNotLoad',
  288. LoadStateLoading = 'LoadStateLoading',
  289. LoadStateLoaded = 'LoadStateLoaded',
  290. }
  291. export const DEFAULT_VECTORS = 100000;
  292. export const DEFAULT_SEFMENT_FILE_SIZE = 1024;
  293. export const DEFAULT_MILVUS_PORT = 19530;
  294. export const DEFAULT_PROMETHEUS_PORT = 9090;
  295. export enum MILVUS_NODE_TYPE {
  296. ROOTCOORD = 'rootcoord',
  297. QUERYCOORD = 'querycoord',
  298. INDEXCOORD = 'indexcoord',
  299. QUERYNODE = 'querynode',
  300. INDEXNODE = 'indexnode',
  301. DATACORD = 'datacord',
  302. DATANODE = 'datanode',
  303. PROXY = 'proxy',
  304. }
  305. export enum MILVUS_DEPLOY_MODE {
  306. DISTRIBUTED = 'DISTRIBUTED',
  307. STANDALONE = 'STANDALONE',
  308. }
  309. export enum ConsistencyLevelEnum {
  310. Strong = 'Strong',
  311. Session = 'Session', // default in PyMilvus
  312. Bounded = 'Bounded',
  313. Eventually = 'Eventually',
  314. Customized = 'Customized', // Users pass their own `guarantee_timestamp`.
  315. }
  316. export const TOP_K_OPTIONS = [15, 50, 100, 150, 200, 250].map(v => ({
  317. value: v,
  318. label: String(v),
  319. }));
  320. export const CONSISTENCY_LEVEL_OPTIONS = [
  321. {
  322. value: ConsistencyLevelEnum.Bounded,
  323. label: ConsistencyLevelEnum.Bounded,
  324. },
  325. {
  326. value: ConsistencyLevelEnum.Strong,
  327. label: ConsistencyLevelEnum.Strong,
  328. },
  329. {
  330. value: ConsistencyLevelEnum.Session,
  331. label: ConsistencyLevelEnum.Session,
  332. },
  333. {
  334. value: ConsistencyLevelEnum.Eventually,
  335. label: ConsistencyLevelEnum.Eventually,
  336. },
  337. ];
  338. export const RERANKER_OPTIONS = [
  339. {
  340. label: 'RRF',
  341. value: 'rrf',
  342. },
  343. {
  344. label: 'Weighted',
  345. value: 'weighted',
  346. },
  347. ];
  348. export enum DataTypeStringEnum {
  349. Bool = 'Bool',
  350. Int8 = 'Int8',
  351. Int16 = 'Int16',
  352. Int32 = 'Int32',
  353. Int64 = 'Int64',
  354. Float = 'Float',
  355. Double = 'Double',
  356. String = 'String',
  357. VarChar = 'VarChar',
  358. JSON = 'JSON',
  359. BinaryVector = 'BinaryVector',
  360. FloatVector = 'FloatVector',
  361. Float16Vector = 'Float16Vector',
  362. BFloat16Vector = 'BFloat16Vector',
  363. SparseFloatVector = 'SparseFloatVector',
  364. Array = 'Array',
  365. None = 'None',
  366. }
  367. export const NONE_INDEXABLE_DATA_TYPES = [
  368. DataTypeStringEnum.Bool,
  369. DataTypeStringEnum.JSON,
  370. DataTypeStringEnum.Array,
  371. ];
  372. export type Property = { key: string; value: any; desc: string; type: string };
  373. export const collectionDefaults: Property[] = [
  374. { key: 'collection.ttl.seconds', value: '', desc: '', type: 'number' },
  375. {
  376. key: 'collection.autocompaction.enabled',
  377. value: '',
  378. desc: '',
  379. type: 'boolean',
  380. },
  381. { key: 'collection.insertRate.max.mb', value: '', desc: '', type: 'number' },
  382. { key: 'collection.insertRate.min.mb', value: '', desc: '', type: 'number' },
  383. { key: 'collection.upsertRate.max.mb', value: '', desc: '', type: 'number' },
  384. { key: 'collection.upsertRate.min.mb', value: '', desc: '', type: 'number' },
  385. { key: 'collection.deleteRate.max.mb', value: '', desc: '', type: 'number' },
  386. { key: 'collection.deleteRate.min.mb', value: '', desc: '', type: 'number' },
  387. {
  388. key: 'collection.bulkLoadRate.max.mb',
  389. value: '',
  390. desc: '',
  391. type: 'number',
  392. },
  393. {
  394. key: 'collection.bulkLoadRate.min.mb',
  395. value: '',
  396. desc: '',
  397. type: 'number',
  398. },
  399. { key: 'collection.queryRate.max.qps', value: '', desc: '', type: 'number' },
  400. { key: 'collection.queryRate.min.qps', value: '', desc: '', type: 'number' },
  401. { key: 'collection.searchRate.max.vps', value: '', desc: '', type: 'number' },
  402. { key: 'collection.searchRate.min.vps', value: '', desc: '', type: 'number' },
  403. {
  404. key: 'collection.diskProtection.diskQuota.mb',
  405. value: '',
  406. desc: '',
  407. type: 'number',
  408. },
  409. { key: 'collection.replica.number', value: '', desc: '', type: 'number' },
  410. { key: 'collection.resource_groups', value: '', desc: '', type: 'string' },
  411. {
  412. key: 'partition.diskProtection.diskQuota.mb',
  413. value: '',
  414. desc: '',
  415. type: 'number',
  416. },
  417. { key: 'mmap.enabled', value: '', desc: '', type: 'boolean' },
  418. { key: 'lazyload.enabled', value: '', desc: '', type: 'boolean' },
  419. { key: 'partitionkey.isolation', value: '', desc: '', type: 'boolean' },
  420. { key: 'indexoffsetcache.enabled', value: '', desc: '', type: 'boolean' },
  421. ];
  422. export const databaseDefaults: Property[] = [
  423. { key: 'database.replica.number', value: '', desc: '', type: 'number' },
  424. { key: 'database.resource_groups', value: '', desc: '', type: 'string' },
  425. { key: 'database.diskQuota.mb', value: '', desc: '', type: 'number' },
  426. { key: 'database.max.collections', value: '', desc: '', type: 'number' },
  427. { key: 'database.force.deny.writing', value: '', desc: '', type: 'boolean' },
  428. ];