Browse Source

Merge pull request #275 from zilliztech/scalar_index

fix scalar index creation
ryjiang 1 year ago
parent
commit
f1802e3d4a

+ 17 - 1
client/src/consts/Milvus.ts

@@ -5,6 +5,22 @@ export const MILVUS_URL =
 
 
 export const DYNAMIC_FIELD = `$meta`;
 export const DYNAMIC_FIELD = `$meta`;
 
 
+export enum INDEX_TYPES_ENUM {
+  AUTO_INDEX = 'AUTO_INDEX',
+  IVF_FLAT = 'IVF_FLAT',
+  IVF_PQ = 'IVF_PQ',
+  IVF_SQ8 = 'IVF_SQ8',
+  IVF_SQ8_HYBRID = 'IVF_SQ8_HYBRID',
+  FLAT = 'FLAT',
+  HNSW = 'HNSW',
+  ANNOY = 'ANNOY',
+  RNSG = 'RNSG',
+  BIN_IVF_FLAT = 'BIN_IVF_FLAT',
+  BIN_FLAT = 'BIN_FLAT',
+  SORT = 'STL_SORT',
+  MARISA_TRIE = 'Trie',
+}
+
 export enum METRIC_TYPES_VALUES {
 export enum METRIC_TYPES_VALUES {
   L2 = 'L2',
   L2 = 'L2',
   IP = 'IP',
   IP = 'IP',
@@ -158,7 +174,7 @@ export const INDEX_OPTIONS_MAP = {
   [DataTypeEnum.VarChar]: [
   [DataTypeEnum.VarChar]: [
     {
     {
       label: 'marisa-trie',
       label: 'marisa-trie',
-      value: 'marisa-trie',
+      value: INDEX_TYPES_ENUM.MARISA_TRIE
     },
     },
   ],
   ],
 };
 };

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

@@ -9,6 +9,7 @@ import {
   INDEX_CONFIG,
   INDEX_CONFIG,
   INDEX_OPTIONS_MAP,
   INDEX_OPTIONS_MAP,
   METRIC_TYPES_VALUES,
   METRIC_TYPES_VALUES,
+  INDEX_TYPES_ENUM,
 } from '@/consts';
 } from '@/consts';
 import { useFormValidation } from '@/hooks';
 import { useFormValidation } from '@/hooks';
 import { getCreateIndexJSCode } from '@/utils/code/Js';
 import { getCreateIndexJSCode } from '@/utils/code/Js';
@@ -23,7 +24,7 @@ import {
 import { DataTypeEnum, DataTypeStringEnum } from '../collections/Types';
 import { DataTypeEnum, DataTypeStringEnum } from '../collections/Types';
 import CreateForm from './CreateForm';
 import CreateForm from './CreateForm';
 import SizingInfo from './SizingInfo';
 import SizingInfo from './SizingInfo';
-import { IndexType, IndexExtraParam, INDEX_TYPES_ENUM } from './Types';
+import { IndexType, IndexExtraParam } from './Types';
 
 
 const CreateIndex = (props: {
 const CreateIndex = (props: {
   collectionName: string;
   collectionName: string;
@@ -140,7 +141,7 @@ const CreateIndex = (props: {
         return INDEX_OPTIONS_MAP[DataTypeEnum.VarChar];
         return INDEX_OPTIONS_MAP[DataTypeEnum.VarChar];
 
 
       default:
       default:
-        return [{ label: 'Ascending', value: 'sort' }];
+        return [{ label: 'STL sort', value: INDEX_TYPES_ENUM.SORT }];
     }
     }
   }, [fieldType]);
   }, [fieldType]);
 
 

+ 1 - 17
client/src/pages/schema/Types.ts

@@ -1,23 +1,7 @@
 import { ReactElement } from 'react';
 import { ReactElement } from 'react';
-import { MetricType } from '@/consts';
+import { MetricType, INDEX_TYPES_ENUM } from '@/consts';
 import { DataTypeStringEnum } from '../collections/Types';
 import { DataTypeStringEnum } from '../collections/Types';
 
 
-export enum INDEX_TYPES_ENUM {
-  AUTO_INDEX = 'AUTO_INDEX',
-  IVF_FLAT = 'IVF_FLAT',
-  IVF_PQ = 'IVF_PQ',
-  IVF_SQ8 = 'IVF_SQ8',
-  IVF_SQ8_HYBRID = 'IVF_SQ8_HYBRID',
-  FLAT = 'FLAT',
-  HNSW = 'HNSW',
-  ANNOY = 'ANNOY',
-  RNSG = 'RNSG',
-  BIN_IVF_FLAT = 'BIN_IVF_FLAT',
-  BIN_FLAT = 'BIN_FLAT',
-  SORT = 'sort',
-  MARISA_TRIE = 'marisa-trie',
-}
-
 export interface Field {
 export interface Field {
   data_type: DataTypeStringEnum;
   data_type: DataTypeStringEnum;
   fieldID: string;
   fieldID: string;

+ 2 - 1
client/src/utils/SizingTool.ts

@@ -1,4 +1,5 @@
-import { INDEX_TYPES_ENUM, SIZE_STATUS } from '../pages/schema/Types';
+import { SIZE_STATUS } from '../pages/schema/Types';
+import { INDEX_TYPES_ENUM } from '@/consts';
 
 
 const commonValueCalculator = (
 const commonValueCalculator = (
   vector: number,
   vector: number,

+ 2 - 6
client/src/utils/search.ts

@@ -1,11 +1,7 @@
 import { Field } from '../components/advancedSearch/Types';
 import { Field } from '../components/advancedSearch/Types';
 import { DataTypeEnum, DataTypeStringEnum } from '../pages/collections/Types';
 import { DataTypeEnum, DataTypeStringEnum } from '../pages/collections/Types';
-import {
-  FieldData,
-  IndexType,
-  IndexView,
-  INDEX_TYPES_ENUM,
-} from '../pages/schema/Types';
+import { FieldData, IndexType, IndexView } from '../pages/schema/Types';
+import { INDEX_TYPES_ENUM } from '@/consts';
 import { FieldOption } from '../types/SearchTypes';
 import { FieldOption } from '../types/SearchTypes';
 
 
 /**
 /**