From 1efa3ef2aa83c15164ed4956a0e135ac7d046936 Mon Sep 17 00:00:00 2001 From: shanghaikid Date: Tue, 19 Sep 2023 20:01:04 +0800 Subject: [PATCH] fix scalar index creation Signed-off-by: shanghaikid --- client/src/consts/Milvus.ts | 18 +++++++++++++++++- client/src/pages/schema/Create.tsx | 5 +++-- client/src/pages/schema/Types.ts | 18 +----------------- client/src/utils/SizingTool.ts | 3 ++- client/src/utils/search.ts | 8 ++------ 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/client/src/consts/Milvus.ts b/client/src/consts/Milvus.ts index 29e36b18..8bdbe8ac 100644 --- a/client/src/consts/Milvus.ts +++ b/client/src/consts/Milvus.ts @@ -5,6 +5,22 @@ export const MILVUS_URL = 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 { L2 = 'L2', IP = 'IP', @@ -158,7 +174,7 @@ export const INDEX_OPTIONS_MAP = { [DataTypeEnum.VarChar]: [ { label: 'marisa-trie', - value: 'marisa-trie', + value: INDEX_TYPES_ENUM.MARISA_TRIE }, ], }; diff --git a/client/src/pages/schema/Create.tsx b/client/src/pages/schema/Create.tsx index da9b3869..3ef075e5 100644 --- a/client/src/pages/schema/Create.tsx +++ b/client/src/pages/schema/Create.tsx @@ -9,6 +9,7 @@ import { INDEX_CONFIG, INDEX_OPTIONS_MAP, METRIC_TYPES_VALUES, + INDEX_TYPES_ENUM, } from '@/consts'; import { useFormValidation } from '@/hooks'; import { getCreateIndexJSCode } from '@/utils/code/Js'; @@ -23,7 +24,7 @@ import { import { DataTypeEnum, DataTypeStringEnum } from '../collections/Types'; import CreateForm from './CreateForm'; import SizingInfo from './SizingInfo'; -import { IndexType, IndexExtraParam, INDEX_TYPES_ENUM } from './Types'; +import { IndexType, IndexExtraParam } from './Types'; const CreateIndex = (props: { collectionName: string; @@ -140,7 +141,7 @@ const CreateIndex = (props: { return INDEX_OPTIONS_MAP[DataTypeEnum.VarChar]; default: - return [{ label: 'Ascending', value: 'sort' }]; + return [{ label: 'STL sort', value: INDEX_TYPES_ENUM.SORT }]; } }, [fieldType]); diff --git a/client/src/pages/schema/Types.ts b/client/src/pages/schema/Types.ts index 7457aa06..45b2404a 100644 --- a/client/src/pages/schema/Types.ts +++ b/client/src/pages/schema/Types.ts @@ -1,23 +1,7 @@ import { ReactElement } from 'react'; -import { MetricType } from '@/consts'; +import { MetricType, INDEX_TYPES_ENUM } from '@/consts'; 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 { data_type: DataTypeStringEnum; fieldID: string; diff --git a/client/src/utils/SizingTool.ts b/client/src/utils/SizingTool.ts index bb66ff49..300a8a5c 100644 --- a/client/src/utils/SizingTool.ts +++ b/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 = ( vector: number, diff --git a/client/src/utils/search.ts b/client/src/utils/search.ts index 2d683079..a41ce5b3 100644 --- a/client/src/utils/search.ts +++ b/client/src/utils/search.ts @@ -1,11 +1,7 @@ import { Field } from '../components/advancedSearch/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'; /**