Browse Source

update insight client

Gitea 3 years ago
parent
commit
fec239d53f

+ 1 - 1
client/src/http/Collection.ts

@@ -134,7 +134,7 @@ export class CollectionHttp extends BaseModel implements CollectionView {
   }
   }
 
 
   // Befor milvus-2.0-rc3  will return '0'.
   // Befor milvus-2.0-rc3  will return '0'.
-  // If milvus is stable, we can remote this condition/
+  // If milvus is stable, we can remote this condition
   get _createdTime(): string {
   get _createdTime(): string {
     return this.createdTime && this.createdTime !== '0'
     return this.createdTime && this.createdTime !== '0'
       ? dayjs(Number(this.createdTime)).format('YYYY-MM-DD HH:mm:ss')
       ? dayjs(Number(this.createdTime)).format('YYYY-MM-DD HH:mm:ss')

+ 1 - 2
client/src/http/Index.ts

@@ -2,7 +2,6 @@ import {
   IndexCreateParam,
   IndexCreateParam,
   IndexManageParam,
   IndexManageParam,
   IndexView,
   IndexView,
-  ParamPair,
 } from '../pages/schema/Types';
 } from '../pages/schema/Types';
 import { ManageRequestMethods } from '../types/Common';
 import { ManageRequestMethods } from '../types/Common';
 import { IndexState } from '../types/Milvus';
 import { IndexState } from '../types/Milvus';
@@ -11,7 +10,7 @@ import { getKeyValueListFromJsonString } from '../utils/Format';
 import BaseModel from './BaseModel';
 import BaseModel from './BaseModel';
 
 
 export class IndexHttp extends BaseModel implements IndexView {
 export class IndexHttp extends BaseModel implements IndexView {
-  params!: ParamPair[];
+  params!: { key: string; value: string }[];
   field_name!: string;
   field_name!: string;
 
 
   constructor(props: {}) {
   constructor(props: {}) {

+ 4 - 1
client/src/pages/collections/Collections.tsx

@@ -172,7 +172,10 @@ const Collections = () => {
       vectorType.includes(v.data_type)
       vectorType.includes(v.data_type)
         ? {
         ? {
             ...v,
             ...v,
-            type_params: [{ key: 'dim', value: v.dimension }],
+            type_params: {
+              // if data type is vector, dimension must exist.
+              dim: v.dimension!,
+            },
           }
           }
         : v
         : v
     );
     );

+ 3 - 1
client/src/pages/collections/Types.ts

@@ -59,7 +59,9 @@ export interface Field {
   dimension?: number | string;
   dimension?: number | string;
   isDefault?: boolean;
   isDefault?: boolean;
   id?: string;
   id?: string;
-  type_params?: { key: string; value: any }[];
+  type_params?: {
+    dim: string | number;
+  };
   createType?: CreateFieldType;
   createType?: CreateFieldType;
 }
 }
 
 

+ 7 - 16
client/src/pages/schema/Create.tsx

@@ -12,12 +12,12 @@ import { formatForm, getMetricOptions } from '../../utils/Form';
 import { getEmbeddingType } from '../../utils/search';
 import { getEmbeddingType } from '../../utils/search';
 import { DataType } from '../collections/Types';
 import { DataType } from '../collections/Types';
 import CreateForm from './CreateForm';
 import CreateForm from './CreateForm';
-import { IndexType, ParamPair, INDEX_TYPES_ENUM } from './Types';
+import { IndexType, IndexExtraParam, INDEX_TYPES_ENUM } from './Types';
 
 
 const CreateIndex = (props: {
 const CreateIndex = (props: {
   collectionName: string;
   collectionName: string;
   fieldType: DataType;
   fieldType: DataType;
-  handleCreate: (params: ParamPair[]) => void;
+  handleCreate: (params: IndexExtraParam) => void;
   handleCancel: () => void;
   handleCancel: () => void;
 }) => {
 }) => {
   const { collectionName, fieldType, handleCreate, handleCancel } = props;
   const { collectionName, fieldType, handleCreate, handleCancel } = props;
@@ -130,20 +130,11 @@ const CreateIndex = (props: {
   const handleCreateIndex = () => {
   const handleCreateIndex = () => {
     const { index_type, metric_type } = indexSetting;
     const { index_type, metric_type } = indexSetting;
 
 
-    const params: ParamPair[] = [
-      {
-        key: 'index_type',
-        value: index_type,
-      },
-      {
-        key: 'metric_type',
-        value: metric_type,
-      },
-      {
-        key: 'params',
-        value: JSON.stringify(indexParams),
-      },
-    ];
+    const params: IndexExtraParam = {
+      index_type,
+      metric_type,
+      params: JSON.stringify(indexParams),
+    };
 
 
     handleCreate(params);
     handleCreate(params);
   };
   };

+ 2 - 2
client/src/pages/schema/IndexTypeElement.tsx

@@ -5,8 +5,8 @@ import { IndexState } from '../../types/Milvus';
 import {
 import {
   FieldView,
   FieldView,
   IndexCreateParam,
   IndexCreateParam,
+  IndexExtraParam,
   IndexManageParam,
   IndexManageParam,
-  ParamPair,
 } from './Types';
 } from './Types';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
 import { makeStyles, Theme } from '@material-ui/core';
 import { makeStyles, Theme } from '@material-ui/core';
@@ -139,7 +139,7 @@ const IndexTypeElement: FC<{
     fetchProgress();
     fetchProgress();
   }, [fetchStatus, fetchProgress]);
   }, [fetchStatus, fetchProgress]);
 
 
-  const requestCreateIndex = async (params: ParamPair[]) => {
+  const requestCreateIndex = async (params: IndexExtraParam) => {
     const indexCreateParam: IndexCreateParam = {
     const indexCreateParam: IndexCreateParam = {
       collection_name: collectionName,
       collection_name: collectionName,
       field_name: data._fieldName,
       field_name: data._fieldName,

+ 5 - 4
client/src/pages/schema/Types.ts

@@ -70,10 +70,11 @@ export interface IndexManageParam {
 }
 }
 
 
 export interface IndexCreateParam extends IndexManageParam {
 export interface IndexCreateParam extends IndexManageParam {
-  extra_params: ParamPair[];
+  extra_params: IndexExtraParam;
 }
 }
 
 
-export interface ParamPair {
-  key: string;
-  value: string;
+export interface IndexExtraParam {
+  index_type: string;
+  metric_type: string;
+  params: string;
 }
 }

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

@@ -51,7 +51,12 @@ export interface SearchParamInputConfig {
 
 
 export interface VectorSearchParam {
 export interface VectorSearchParam {
   expr?: string;
   expr?: string;
-  search_params: { key: string; value: string | number }[];
+  search_params: {
+    anns_field: string; // your vector field name
+    topk: string | number;
+    metric_type: string;
+    params: string;
+  };
   vectors: any;
   vectors: any;
   output_fields: string[];
   output_fields: string[];
   vector_type: number | DataTypeEnum;
   vector_type: number | DataTypeEnum;

+ 8 - 22
client/src/pages/seach/VectorSearch.tsx

@@ -58,9 +58,8 @@ const VectorSearch = () => {
   // search params disable state
   // search params disable state
   const [paramDisabled, setParamDisabled] = useState<boolean>(true);
   const [paramDisabled, setParamDisabled] = useState<boolean>(true);
   // use null as init value before search, empty array means no results
   // use null as init value before search, empty array means no results
-  const [searchResult, setSearchResult] = useState<SearchResultView[] | null>(
-    null
-  );
+  const [searchResult, setSearchResult] =
+    useState<SearchResultView[] | null>(null);
   // default topK is 100
   // default topK is 100
   const [topK, setTopK] = useState<number>(100);
   const [topK, setTopK] = useState<number>(100);
   const [expression, setExpression] = useState<string>('');
   const [expression, setExpression] = useState<string>('');
@@ -258,25 +257,12 @@ const VectorSearch = () => {
     setExpression('');
     setExpression('');
   };
   };
   const handleSearch = async (topK: number, expr = expression) => {
   const handleSearch = async (topK: number, expr = expression) => {
-    const searhParamPairs = [
-      // dynamic search params
-      {
-        key: 'params',
-        value: JSON.stringify(searchParam),
-      },
-      {
-        key: 'anns_field',
-        value: selectedField,
-      },
-      {
-        key: 'topk',
-        value: topK,
-      },
-      {
-        key: 'metric_type',
-        value: metricType,
-      },
-    ];
+    const searhParamPairs = {
+      params: JSON.stringify(searchParam),
+      anns_field: selectedField,
+      topk: topK,
+      metric_type: metricType,
+    };
 
 
     const params: VectorSearchParam = {
     const params: VectorSearchParam = {
       output_fields: outputFields,
       output_fields: outputFields,

+ 1 - 0
server/src/schema/dto.ts

@@ -52,6 +52,7 @@ export class ManageIndex {
     type: [KeyValuePair],
     type: [KeyValuePair],
   })
   })
   @IsObject()
   @IsObject()
+  @IsOptional()
   readonly extra_params?: CreateIndexParam;
   readonly extra_params?: CreateIndexParam;
 }
 }