Browse Source

fix search page UI

Signed-off-by: ruiyi.jiang <ruiyi.jiang@zilliz.com>
ruiyi.jiang 1 year ago
parent
commit
22a6d49f0a

+ 1 - 1
client/src/i18n/cn/search.ts

@@ -1,7 +1,7 @@
 const searchTrans = {
   firstTip: '2. 输入搜索向量 {{dimensionTip}}',
   secondTip: '1. 选择Collection和字段',
-  thirdTip: '搜索参数',
+  thirdTip: '搜索参数 {{metricType}}',
   vectorPlaceholder: '请在此输入您的向量值,例如 [1, 2, 3, 4]',
   collection: '已加载的Collection',
   noCollection: '没有已加载的Collection',

+ 1 - 1
client/src/i18n/en/search.ts

@@ -1,7 +1,7 @@
 const searchTrans = {
   firstTip: '2. Enter search vector {{dimensionTip}}',
   secondTip: '1. Choose collection and field',
-  thirdTip: 'Search Parameters',
+  thirdTip: 'Search Parameters {{metricType}}',
   vectorPlaceholder: 'Please input your vector value here, e.g. [1, 2, 3, 4]',
   collection: 'loaded collection',
   noCollection: 'No loaded collection',

+ 2 - 8
client/src/pages/search/SearchParams.tsx

@@ -4,14 +4,13 @@ import { useTranslation } from 'react-i18next';
 import CustomInput from '@/components/customInput/CustomInput';
 import { ITextfieldConfig } from '@/components/customInput/Types';
 import CustomSelector from '@/components/customSelector/CustomSelector';
-import { Option } from '@/components/customSelector/Types';
 import {
   DEFAULT_NLIST_VALUE,
   DEFAULT_SEARCH_PARAM_VALUE_MAP,
   INDEX_CONFIG,
-  METRIC_OPTIONS_MAP,
   searchKeywordsType,
   CONSISTENCY_LEVEL_OPTIONS,
+  ConsistencyLevelEnum,
 } from '@/consts';
 import { rootContext } from '@/context';
 import { useFormValidation } from '@/hooks';
@@ -40,22 +39,17 @@ const SearchParams: FC<SearchParamsProps> = ({
   indexParams,
   searchParamsForm,
   handleFormChange,
-  handleMetricTypeChange,
   handleConsistencyChange,
-  embeddingType,
-  metricType,
   consistency_level,
   topK,
   setParamsDisabled,
   wrapperClass = '',
 }) => {
-  const { t: indexTrans } = useTranslation('index');
   const { t: collectionTrans } = useTranslation('collection');
   const { t: warningTrans } = useTranslation('warning');
   const classes = getStyles();
 
   const { openSnackBar } = useContext(rootContext);
-  const metricOptions: Option[] = METRIC_OPTIONS_MAP[embeddingType];
 
   // search params key list, depends on index type
   // e.g. ['nprobe']
@@ -325,7 +319,7 @@ const SearchParams: FC<SearchParamsProps> = ({
       {/* consistency level */}
       <CustomSelector
         options={CONSISTENCY_LEVEL_OPTIONS}
-        value={consistency_level}
+        value={consistency_level || ConsistencyLevelEnum.Bounded}
         label={collectionTrans('consistencyLevel')}
         wrapperClass={classes.selector}
         variant="filled"

+ 0 - 6
client/src/pages/search/Types.ts

@@ -4,11 +4,6 @@ import { DataTypeEnum, DataTypeStringEnum } from '@/consts';
 import { MilvusIndex } from '@/http';
 
 export interface SearchParamsProps {
-  // if user created index, pass metric type choosed when creating
-  // else pass empty string
-  metricType: string;
-  // used for getting metric type options
-  embeddingType: DataTypeEnum.FloatVector | DataTypeEnum.BinaryVector;
   // default index type is FLAT
   indexType: string;
   // index extra params, e.g. nlist
@@ -18,7 +13,6 @@ export interface SearchParamsProps {
   };
   topK: number;
   handleFormChange: (form: { [key in string]: number }) => void;
-  handleMetricTypeChange: (type: string) => void;
   handleConsistencyChange: (type: string) => void;
   wrapperClass?: string;
   setParamsDisabled: (isDisabled: boolean) => void;

+ 5 - 8
client/src/pages/search/VectorSearch.tsx

@@ -470,16 +470,14 @@ const VectorSearch = () => {
 
         <CardContent className={classes.s3}>
           <Typography className="text">
-            {searchTrans('thirdTip')} ({selectedMetricType})
+            {searchTrans('thirdTip', {
+              metricType: `${
+                selectedMetricType ? `(${selectedMetricType})` : ''
+              }`,
+            })}
           </Typography>
           <SearchParams
             wrapperClass={classes.paramsWrapper}
-            metricType={selectedMetricType}
-            embeddingType={
-              embeddingType as
-                | DataTypeEnum.BinaryVector
-                | DataTypeEnum.FloatVector
-            }
             consistency_level={selectedConsistencyLevel}
             handleConsistencyChange={(level: string) => {
               setSelectedConsistencyLevel(level);
@@ -488,7 +486,6 @@ const VectorSearch = () => {
             indexParams={indexParams!}
             searchParamsForm={searchParam}
             handleFormChange={setSearchParam}
-            handleMetricTypeChange={setSelectedMetricType}
             topK={topK}
             setParamsDisabled={setParamDisabled}
           />