Browse Source

fix range search

Signed-off-by: shanghaikid <jiangruiyi@gmail.com>
shanghaikid 1 year ago
parent
commit
5cd4f5cfff

+ 3 - 2
client/src/components/customSnackBar/CustomSnackBar.tsx

@@ -19,7 +19,8 @@ const useStyles = makeStyles((theme: Theme) =>
   createStyles({
   createStyles({
     root: {
     root: {
       borderRadius: '4px',
       borderRadius: '4px',
-      maxWidth: '300px',
+      maxWidth: '50vh',
+      wordBreak: 'break-all'
     },
     },
     topRight: {
     topRight: {
       [theme.breakpoints.up('md')]: {
       [theme.breakpoints.up('md')]: {
@@ -37,7 +38,7 @@ const CustomSnackBar: FC<CustomSnackBarType> = props => {
     vertical,
     vertical,
     horizontal,
     horizontal,
     open,
     open,
-    autoHideDuration = 2000,
+    autoHideDuration = 2500,
     type,
     type,
     message,
     message,
     onClose,
     onClose,

+ 2 - 5
client/src/consts/Milvus.ts

@@ -67,7 +67,7 @@ export type searchKeywordsType =
   | 'round_decimal'
   | 'round_decimal'
   | 'level'
   | 'level'
   | 'search_list'
   | 'search_list'
-  | 'range'
+  | 'radius'
   | 'range_filter';
   | 'range_filter';
 
 
 export type indexConfigType = {
 export type indexConfigType = {
@@ -211,7 +211,7 @@ export const DEFAULT_METRIC_VALUE_MAP = {
 
 
 // search params default value map
 // search params default value map
 export const DEFAULT_SEARCH_PARAM_VALUE_MAP: {
 export const DEFAULT_SEARCH_PARAM_VALUE_MAP: {
-  [key in searchKeywordsType]: number;
+  [key in searchKeywordsType]?: number;
 } = {
 } = {
   // range: [top_k, 32768]
   // range: [top_k, 32768]
   ef: 250,
   ef: 250,
@@ -221,11 +221,8 @@ export const DEFAULT_SEARCH_PARAM_VALUE_MAP: {
   search_k: 250,
   search_k: 250,
   // range: [10, 300]
   // range: [10, 300]
   search_length: 10,
   search_length: 10,
-  round_decimal: -1,
   level: 1,
   level: 1,
   search_list: 20,
   search_list: 20,
-  range: 20,
-  range_filter: 10
 };
 };
 
 
 export const DEFAULT_NLIST_VALUE = 1024;
 export const DEFAULT_NLIST_VALUE = 1024;

+ 1 - 1
client/src/context/Root.tsx

@@ -61,7 +61,7 @@ export const RootProvider = (props: { children: React.ReactNode }) => {
     message: '',
     message: '',
     vertical: 'top',
     vertical: 'top',
     horizontal: 'right',
     horizontal: 'right',
-    autoHideDuration: 3000,
+    autoHideDuration: 1000,
   });
   });
   const [dialog, setDialog] = useState<DialogType>(DefaultDialogConfigs);
   const [dialog, setDialog] = useState<DialogType>(DefaultDialogConfigs);
   const [drawer, setDrawer]: any = useState({
   const [drawer, setDrawer]: any = useState({

+ 35 - 34
client/src/pages/search/SearchParams.tsx

@@ -68,7 +68,7 @@ const SearchParams: FC<SearchParamsProps> = ({
     }
     }
 
 
     const commonParams: searchKeywordsType[] = [
     const commonParams: searchKeywordsType[] = [
-      'range',
+      'radius',
       'range_filter',
       'range_filter',
       'round_decimal',
       'round_decimal',
     ];
     ];
@@ -78,8 +78,14 @@ const SearchParams: FC<SearchParamsProps> = ({
   }, [indexType, openSnackBar, warningTrans]);
   }, [indexType, openSnackBar, warningTrans]);
 
 
   const handleInputChange = useCallback(
   const handleInputChange = useCallback(
-    (key: string, value: number) => {
-      const form = { ...searchParamsForm, [key]: value };
+    (key: string, value: number | string) => {
+      let form = { ...searchParamsForm };
+      if (value === '') {
+        delete form[key];
+      } else {
+        form = { ...searchParamsForm, [key]: Number(value) };
+      }
+
       handleFormChange(form);
       handleFormChange(form);
     },
     },
     [handleFormChange, searchParamsForm]
     [handleFormChange, searchParamsForm]
@@ -98,6 +104,7 @@ const SearchParams: FC<SearchParamsProps> = ({
         value,
         value,
         handleChange,
         handleChange,
         isInt = true,
         isInt = true,
+        required = true,
       } = params;
       } = params;
 
 
       // search_k range is special compared to others,need to be handled separately
       // search_k range is special compared to others,need to be handled separately
@@ -114,22 +121,13 @@ const SearchParams: FC<SearchParamsProps> = ({
         variant: 'filled',
         variant: 'filled',
         type: 'number',
         type: 'number',
         value,
         value,
-        validations: [
-          {
-            rule: 'require',
-            errorText: warningTrans('required', { name: label }),
-          },
-        ],
+        validations: [],
       };
       };
-      if (!isSearchK && min && max) {
+
+      if (required) {
         config.validations?.push({
         config.validations?.push({
-          rule: 'range',
-          errorText: warningTrans('range', { min, max }),
-          extraParam: {
-            min,
-            max,
-            type: 'number',
-          },
+          rule: 'require',
+          errorText: warningTrans('required', { name: label }),
         });
         });
       }
       }
 
 
@@ -174,14 +172,15 @@ const SearchParams: FC<SearchParamsProps> = ({
         [key in searchKeywordsType]: SearchParamInputConfig;
         [key in searchKeywordsType]: SearchParamInputConfig;
       } = {
       } = {
         round_decimal: {
         round_decimal: {
-          label: 'Round',
+          label: 'round',
           key: 'round_decimal',
           key: 'round_decimal',
           value: searchParamsForm['round_decimal'] || '',
           value: searchParamsForm['round_decimal'] || '',
           min: -1,
           min: -1,
           max: 10,
           max: 10,
           isInt: true,
           isInt: true,
+          required: false,
           handleChange: value => {
           handleChange: value => {
-            handleInputChange('round_decimal', Number(value));
+            handleInputChange('round_decimal', value);
           },
           },
           className: classes.inlineInput,
           className: classes.inlineInput,
         },
         },
@@ -193,31 +192,33 @@ const SearchParams: FC<SearchParamsProps> = ({
           max: nlist,
           max: nlist,
           isInt: true,
           isInt: true,
           handleChange: value => {
           handleChange: value => {
-            handleInputChange('nprobe', Number(value));
+            handleInputChange('nprobe', value);
           },
           },
           className: classes.inlineInput,
           className: classes.inlineInput,
         },
         },
-        range: {
-          label: 'range',
-          key: 'range',
-          value: searchParamsForm['range'] || '',
+        radius: {
+          label: 'radius',
+          key: 'radius',
+          value: searchParamsForm['radius'] || '',
           min: 1,
           min: 1,
-          max: 500,
+          max: 1024,
           isInt: false,
           isInt: false,
+          required: false,
           handleChange: value => {
           handleChange: value => {
-            handleInputChange('range', Number(value));
+            handleInputChange('radius', value);
           },
           },
           className: classes.inlineInput,
           className: classes.inlineInput,
         },
         },
         range_filter: {
         range_filter: {
-          label: 'range_filter',
+          label: 'range filter',
           key: 'range_filter',
           key: 'range_filter',
           value: searchParamsForm['range_filter'] || '',
           value: searchParamsForm['range_filter'] || '',
           min: 1,
           min: 1,
-          max: 500,
+          max: 1024,
           isInt: false,
           isInt: false,
+          required: false,
           handleChange: value => {
           handleChange: value => {
-            handleInputChange('range_filter', Number(value));
+            handleInputChange('range_filter', value);
           },
           },
           className: classes.inlineInput,
           className: classes.inlineInput,
         },
         },
@@ -229,7 +230,7 @@ const SearchParams: FC<SearchParamsProps> = ({
           max: 32768,
           max: 32768,
           isInt: true,
           isInt: true,
           handleChange: value => {
           handleChange: value => {
-            handleInputChange('ef', Number(value));
+            handleInputChange('ef', value);
           },
           },
         },
         },
         level: {
         level: {
@@ -240,7 +241,7 @@ const SearchParams: FC<SearchParamsProps> = ({
           max: 3,
           max: 3,
           isInt: true,
           isInt: true,
           handleChange: value => {
           handleChange: value => {
-            handleInputChange('level', Number(value));
+            handleInputChange('level', value);
           },
           },
         },
         },
         search_k: {
         search_k: {
@@ -252,7 +253,7 @@ const SearchParams: FC<SearchParamsProps> = ({
           max: Infinity,
           max: Infinity,
           isInt: true,
           isInt: true,
           handleChange: value => {
           handleChange: value => {
-            handleInputChange('search_k', Number(value));
+            handleInputChange('search_k', value);
           },
           },
         },
         },
         search_length: {
         search_length: {
@@ -263,7 +264,7 @@ const SearchParams: FC<SearchParamsProps> = ({
           max: 300,
           max: 300,
           isInt: true,
           isInt: true,
           handleChange: value => {
           handleChange: value => {
-            handleInputChange('search_length', Number(value));
+            handleInputChange('search_length', value);
           },
           },
         },
         },
         search_list: {
         search_list: {
@@ -274,7 +275,7 @@ const SearchParams: FC<SearchParamsProps> = ({
           max: 65535,
           max: 65535,
           isInt: true,
           isInt: true,
           handleChange: value => {
           handleChange: value => {
-            handleInputChange('search_list', Number(value));
+            handleInputChange('search_list', value);
           },
           },
         },
         },
       };
       };

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

@@ -52,6 +52,7 @@ export interface SearchParamInputConfig {
   value: number | string;
   value: number | string;
   handleChange: (value: number) => void;
   handleChange: (value: number) => void;
   className?: string;
   className?: string;
+  required?: boolean;
 }
 }
 
 
 export interface VectorSearchParam {
 export interface VectorSearchParam {

+ 1 - 11
client/src/pages/search/VectorSearch.tsx

@@ -3,12 +3,7 @@ import { Typography, Button, Card, CardContent } from '@material-ui/core';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
 import { useLocation } from 'react-router-dom';
 import { useLocation } from 'react-router-dom';
 import { ALL_ROUTER_TYPES } from '@/router/Types';
 import { ALL_ROUTER_TYPES } from '@/router/Types';
-import {
-  useNavigationHook,
-  useSearchResult,
-  usePaginationHook,
-  useTimeTravelHook,
-} from '@/hooks';
+import { useNavigationHook, useSearchResult, usePaginationHook } from '@/hooks';
 import { dataContext } from '@/context';
 import { dataContext } from '@/context';
 import CustomSelector from '@/components/customSelector/CustomSelector';
 import CustomSelector from '@/components/customSelector/CustomSelector';
 import { ColDefinitionsType } from '@/components/grid/Types';
 import { ColDefinitionsType } from '@/components/grid/Types';
@@ -92,9 +87,6 @@ const VectorSearch = () => {
     handleGridSort,
     handleGridSort,
   } = usePaginationHook(searchResultMemo || []);
   } = usePaginationHook(searchResultMemo || []);
 
 
-  const { timeTravel, setTimeTravel, timeTravelInfo, handleDateTimeChange } =
-    useTimeTravelHook();
-
   const collectionOptions: Option[] = useMemo(
   const collectionOptions: Option[] = useMemo(
     () =>
     () =>
       collections.map(c => ({
       collections.map(c => ({
@@ -317,7 +309,6 @@ const VectorSearch = () => {
     setSearchResult(null);
     setSearchResult(null);
     setFilterFields([]);
     setFilterFields([]);
     setExpression('');
     setExpression('');
-    setTimeTravel(null);
   };
   };
 
 
   const handleSearch = async (topK: number, expr = expression) => {
   const handleSearch = async (topK: number, expr = expression) => {
@@ -337,7 +328,6 @@ const VectorSearch = () => {
       search_params: searchParamPairs,
       search_params: searchParamPairs,
       vectors: [parseValue(vectors)],
       vectors: [parseValue(vectors)],
       vector_type: fieldType,
       vector_type: fieldType,
-      travel_timestamp: timeTravelInfo.timestamp,
     };
     };
 
 
     setTableLoading(true);
     setTableLoading(true);