Procházet zdrojové kódy

Reduce manual spelling

Min Tian před 4 roky
rodič
revize
b48277f089

+ 18 - 10
client/src/consts/Milvus.tsx

@@ -50,13 +50,15 @@ export type MetricType =
 
 export type searchKeywordsType = 'nprobe' | 'ef' | 'search_k' | 'search_length';
 
-// index
-export const INDEX_CONFIG: {
+export type indexConfigType = {
   [x: string]: {
     create: string[];
     search: searchKeywordsType[];
   };
-} = {
+}
+
+// index
+export const FLOAT_INDEX_CONFIG: indexConfigType = {
   IVF_FLAT: {
     create: ['nlist'],
     search: ['nprobe'],
@@ -88,7 +90,10 @@ export const INDEX_CONFIG: {
   // RNSG: {
   //   create: ['out_degree', 'candidate_pool_size', 'search_length', 'knng'],
   //   search: ['search_length'],
-  // },
+  // },}
+}
+
+export const BINARY_INDEX_CONFIG: indexConfigType = {
   BIN_FLAT: {
     create: ['nlist'],
     search: ['nprobe'],
@@ -99,6 +104,11 @@ export const INDEX_CONFIG: {
   },
 };
 
+export const INDEX_CONFIG: indexConfigType = {
+  ...FLOAT_INDEX_CONFIG,
+  ...BINARY_INDEX_CONFIG,
+};
+
 export const COLLECTION_NAME_REGX = /^[0-9,a-z,A-Z$_]+$/;
 
 export const m_OPTIONS = [
@@ -110,15 +120,13 @@ export const m_OPTIONS = [
 ];
 
 export const INDEX_OPTIONS_MAP = {
-  // not all
-  // FLOAT_POINT: Object.keys(INDEX_CONFIG).map(v => ({ label: v, value: v })),
-  FLOAT_POINT: ['IVF_FLAT', 'IVF_PQ', 'FLAT', 'HNSW', 'ANNOY',].map(v => ({ label: v, value: v })),
-  BINARY: ['BIN_IVF_FLAT', 'BIN_FLAT'].map(v => ({ label: v, value: v })),
+  FLOAT_INDEX: Object.keys(FLOAT_INDEX_CONFIG).map(v => ({ label: v, value: v })),
+  BINARY_INDEX: Object.keys(BINARY_INDEX_CONFIG).map(v => ({ label: v, value: v })),
 };
 
 export const PRIMARY_KEY_FIELD = 'INT64 (Primary key)';
 
 export enum EmbeddingTypeEnum {
-  float = 'FLOAT_POINT',
-  binary = 'BINARY',
+  float = 'FLOAT_INDEX',
+  binary = 'BINARY_INDEX',
 }

+ 4 - 3
client/src/pages/schema/Create.tsx

@@ -6,12 +6,13 @@ import {
   INDEX_CONFIG,
   INDEX_OPTIONS_MAP,
   MetricType,
+  METRIC_TYPES_VALUES,
 } from '../../consts/Milvus';
 import { useFormValidation } from '../../hooks/Form';
 import { formatForm, getMetricOptions } from '../../utils/Form';
 import { DataType } from '../collections/Types';
 import CreateForm from './CreateForm';
-import { IndexType, ParamPair } from './Types';
+import { IndexType, ParamPair, INDEX_TYPES_ENUM } from './Types';
 
 const CreateIndex = (props: {
   collectionName: string;
@@ -25,8 +26,8 @@ const CreateIndex = (props: {
   const { t: dialogTrans } = useTranslation('dialog');
   const { t: btnTrans } = useTranslation('btn');
 
-  const defaultIndexType = fieldType === 'BinaryVector' ? 'BIN_IVF_FLAT': 'IVF_FLAT';
-  const defaultMetricType = fieldType === 'BinaryVector' ? 'HAMMING' : 'L2';
+  const defaultIndexType = fieldType === 'BinaryVector' ? INDEX_TYPES_ENUM.BIN_IVF_FLAT : INDEX_TYPES_ENUM.IVF_FLAT;
+  const defaultMetricType = fieldType === 'BinaryVector' ? METRIC_TYPES_VALUES.HAMMING : METRIC_TYPES_VALUES.L2;
 
   const [indexSetting, setIndexSetting] = useState<{
     index_type: IndexType;

+ 9 - 7
client/src/pages/schema/Types.ts

@@ -10,6 +10,8 @@ export enum INDEX_TYPES_ENUM {
   HNSW = 'HNSW',
   ANNOY = 'ANNOY',
   RNSG = 'RNSG',
+  BIN_IVF_FLAT = 'BIN_IVF_FLAT',
+  BIN_FLAT = 'BIN_FLAT',
 }
 
 export interface Field {
@@ -48,16 +50,16 @@ export interface IndexView {
 }
 
 export type IndexType =
-  | 'FLAT'
-  | 'IVF_FLAT'
+  | INDEX_TYPES_ENUM.FLAT
+  | INDEX_TYPES_ENUM.IVF_FLAT
   // | 'IVF_SQ8'
   // | 'IVF_SQ8_HYBRID'
-  | 'IVF_PQ'
+  | INDEX_TYPES_ENUM.IVF_PQ
   // | 'RNSG'
-  | 'HNSW'
-  | 'ANNOY'
-  | 'BIN_IVF_FLAT'
-  | 'BIN_FLAT';
+  | INDEX_TYPES_ENUM.HNSW
+  | INDEX_TYPES_ENUM.ANNOY
+  | INDEX_TYPES_ENUM.BIN_IVF_FLAT
+  | INDEX_TYPES_ENUM.BIN_FLAT
 
 
 export interface IndexManageParam {