Browse Source

Add round_decimal and upate sdk

Signed-off-by: Gitea <zizhao.chen@zilliz.com>
Gitea 3 years ago
parent
commit
7ec22b8b37

+ 5 - 5
client/src/components/layout/Layout.tsx

@@ -68,11 +68,11 @@ const Layout = (props: any) => {
       label: navTrans('overview'),
       label: navTrans('overview'),
       onClick: () => history.push('/'),
       onClick: () => history.push('/'),
     },
     },
-    {
-      icon: icons.navSystem,
-      label: navTrans('system'),
-      onClick: () => history.push('/system'),
-    },
+    // {
+    //   icon: icons.navSystem,
+    //   label: navTrans('system'),
+    //   onClick: () => history.push('/system'),
+    // },
     {
     {
       icon: icons.navCollection,
       icon: icons.navCollection,
       label: navTrans('collection'),
       label: navTrans('collection'),

+ 7 - 1
client/src/consts/Milvus.tsx

@@ -50,7 +50,12 @@ export type MetricType =
   | 'JACCARD'
   | 'JACCARD'
   | 'TANIMOTO';
   | 'TANIMOTO';
 
 
-export type searchKeywordsType = 'nprobe' | 'ef' | 'search_k' | 'search_length';
+export type searchKeywordsType =
+  | 'nprobe'
+  | 'ef'
+  | 'search_k'
+  | 'search_length'
+  | 'round_decimal';
 
 
 export type indexConfigType = {
 export type indexConfigType = {
   [x: string]: {
   [x: string]: {
@@ -191,6 +196,7 @@ 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,
 };
 };
 
 
 export const DEFAULT_NLIST_VALUE = 1024;
 export const DEFAULT_NLIST_VALUE = 1024;

+ 42 - 15
client/src/pages/seach/SearchParams.tsx

@@ -24,6 +24,14 @@ const getStyles = makeStyles((theme: Theme) => ({
   input: {
   input: {
     marginTop: theme.spacing(2),
     marginTop: theme.spacing(2),
   },
   },
+  inlineInput: {
+    marginTop: theme.spacing(2),
+    width: '48%',
+  },
+  inlineInputWrapper: {
+    display: 'flex',
+    justifyContent: 'space-between',
+  },
 }));
 }));
 
 
 const SearchParams: FC<SearchParamsProps> = ({
 const SearchParams: FC<SearchParamsProps> = ({
@@ -46,7 +54,10 @@ const SearchParams: FC<SearchParamsProps> = ({
   // search params key list, depends on index type
   // search params key list, depends on index type
   // e.g. ['nprobe']
   // e.g. ['nprobe']
   const searchParams = useMemo(
   const searchParams = useMemo(
-    () => (indexType !== '' ? INDEX_CONFIG[indexType].search : []),
+    (): searchKeywordsType[] =>
+      indexType !== ''
+        ? [...INDEX_CONFIG[indexType].search, 'round_decimal']
+        : ['round_decimal'],
     [indexType]
     [indexType]
   );
   );
 
 
@@ -83,7 +94,7 @@ const SearchParams: FC<SearchParamsProps> = ({
         onChange: value => {
         onChange: value => {
           handleChange(value);
           handleChange(value);
         },
         },
-        className: classes.input,
+        className: classes.inlineInput,
         variant: 'filled',
         variant: 'filled',
         type: 'number',
         type: 'number',
         value,
         value,
@@ -133,7 +144,7 @@ const SearchParams: FC<SearchParamsProps> = ({
       }
       }
       return config;
       return config;
     },
     },
-    [warningTrans, classes.input]
+    [classes.inlineInput, warningTrans]
   );
   );
 
 
   const getSearchInputConfig = useCallback(
   const getSearchInputConfig = useCallback(
@@ -146,6 +157,18 @@ const SearchParams: FC<SearchParamsProps> = ({
       const configParamMap: {
       const configParamMap: {
         [key in searchKeywordsType]: SearchParamInputConfig;
         [key in searchKeywordsType]: SearchParamInputConfig;
       } = {
       } = {
+        round_decimal: {
+          label: 'round_decimal',
+          key: 'round_decimal',
+          value: searchParamsForm['round_decimal'] || '',
+          min: -1,
+          max: 10,
+          isInt: true,
+          handleChange: value => {
+            handleInputChange('round_decimal', value);
+          },
+          className: classes.inlineInput,
+        },
         nprobe: {
         nprobe: {
           label: 'nprobe',
           label: 'nprobe',
           key: 'nprobe',
           key: 'nprobe',
@@ -156,7 +179,9 @@ const SearchParams: FC<SearchParamsProps> = ({
           handleChange: value => {
           handleChange: value => {
             handleInputChange('nprobe', value);
             handleInputChange('nprobe', value);
           },
           },
+          className: classes.inlineInput,
         },
         },
+
         ef: {
         ef: {
           label: 'ef',
           label: 'ef',
           key: 'ef',
           key: 'ef',
@@ -198,8 +223,9 @@ const SearchParams: FC<SearchParamsProps> = ({
     },
     },
     [
     [
       indexParams,
       indexParams,
-      topK,
       searchParamsForm,
       searchParamsForm,
+      classes.inlineInput,
+      topK,
       getNumberInputConfig,
       getNumberInputConfig,
       handleInputChange,
       handleInputChange,
     ]
     ]
@@ -244,17 +270,18 @@ const SearchParams: FC<SearchParamsProps> = ({
         // readOnly can't avoid all events, so we use disabled instead
         // readOnly can't avoid all events, so we use disabled instead
         disabled={true}
         disabled={true}
       />
       />
-
-      {/* dynamic params, now every type only has one param except metric type */}
-      {searchParams.map(param => (
-        <CustomInput
-          key={param}
-          type="text"
-          textConfig={getSearchInputConfig(param)}
-          checkValid={checkIsValid}
-          validInfo={validation}
-        />
-      ))}
+      <div className={classes.inlineInputWrapper}>
+        {/* dynamic params, now every type only has one param except metric type */}
+        {searchParams.map(param => (
+          <CustomInput
+            key={param}
+            type="text"
+            textConfig={getSearchInputConfig(param)}
+            checkValid={checkIsValid}
+            validInfo={validation}
+          />
+        ))}
+      </div>
     </div>
     </div>
   );
   );
 };
 };

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

@@ -47,6 +47,7 @@ export interface SearchParamInputConfig {
   // no value: empty string
   // no value: empty string
   value: number | string;
   value: number | string;
   handleChange: (value: number) => void;
   handleChange: (value: number) => void;
+  className?: string;
 }
 }
 
 
 export interface VectorSearchParam {
 export interface VectorSearchParam {

+ 1 - 0
client/src/pages/seach/VectorSearch.tsx

@@ -289,6 +289,7 @@ const VectorSearch = () => {
       anns_field: selectedField,
       anns_field: selectedField,
       topk: topK,
       topk: topK,
       metric_type: metricType,
       metric_type: metricType,
+      round_decimal: searchParam.round_decimal,
     };
     };
 
 
     const params: VectorSearchParam = {
     const params: VectorSearchParam = {

+ 11 - 7
client/src/utils/search.ts

@@ -12,16 +12,20 @@ import {
   SearchResultView,
   SearchResultView,
 } from '../pages/seach/Types';
 } from '../pages/seach/Types';
 
 
+/**
+ * Do not change  vector search result default sort  by ourself.
+ * Different index may has different sort in milvus.
+ * @param result
+ * @returns
+ */
 export const transferSearchResult = (
 export const transferSearchResult = (
   result: SearchResult[]
   result: SearchResult[]
 ): SearchResultView[] => {
 ): SearchResultView[] => {
-  const resultView = result
-    .sort((a, b) => a.score - b.score)
-    .map((r, index) => ({
-      rank: index + 1,
-      ...r,
-      distance: r.score,
-    }));
+  const resultView = result.map((r, index) => ({
+    rank: index + 1,
+    ...r,
+    distance: r.score,
+  }));
 
 
   return resultView;
   return resultView;
 };
 };

+ 0 - 0
plugins/server/package.json


+ 1 - 1
server/package.json

@@ -33,7 +33,7 @@
     "@nestjs/websockets": "^8.0.4",
     "@nestjs/websockets": "^8.0.4",
     "@types/passport-jwt": "^3.0.5",
     "@types/passport-jwt": "^3.0.5",
     "@types/passport-local": "^1.0.33",
     "@types/passport-local": "^1.0.33",
-    "@zilliz/milvus2-sdk-node": "^1.0.17",
+    "@zilliz/milvus2-sdk-node": "^1.0.18",
     "axios": "^0.21.3",
     "axios": "^0.21.3",
     "body-parser": "^1.19.0",
     "body-parser": "^1.19.0",
     "cache-manager": "^3.4.4",
     "cache-manager": "^3.4.4",

+ 4 - 4
server/yarn.lock

@@ -1425,10 +1425,10 @@
   resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
   resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
   integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==
   integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==
 
 
-"@zilliz/milvus2-sdk-node@^1.0.17":
-  version "1.0.17"
-  resolved "https://registry.yarnpkg.com/@zilliz/milvus2-sdk-node/-/milvus2-sdk-node-1.0.17.tgz#af0b132c6896147dadb73f0050eb6b95ce47908a"
-  integrity sha512-eCkCd8P0QGKXMKyzdE67INK0WSfgBfYTBQrnsZIjBdLJkUa8saWX8G60ayQt0o5W4nj0tfu+OwKL5RXzhhOSLw==
+"@zilliz/milvus2-sdk-node@^1.0.18":
+  version "1.0.18"
+  resolved "https://registry.yarnpkg.com/@zilliz/milvus2-sdk-node/-/milvus2-sdk-node-1.0.18.tgz#8f445823a952d8dfff5e057c496d19d67c891f81"
+  integrity sha512-D7N/2W1fwWlhm0dM4Y/+tph5O6v2Qa3Phbux6CIlz4LocX+Z/rt5L0OLInrNLPNZSkaHz+AxbDz1MLdeqiOZkg==
   dependencies:
   dependencies:
     "@grpc/grpc-js" "^1.2.12"
     "@grpc/grpc-js" "^1.2.12"
     "@grpc/proto-loader" "^0.6.0"
     "@grpc/proto-loader" "^0.6.0"