Browse Source

Merge pull request #307 from zilliztech/attu-305

hide create index button if the data type is none-indexable
ryjiang 1 year ago
parent
commit
f259d1ff00

+ 21 - 1
client/src/consts/Milvus.ts

@@ -174,7 +174,7 @@ export const INDEX_OPTIONS_MAP = {
   [DataTypeEnum.VarChar]: [
     {
       label: 'marisa-trie',
-      value: INDEX_TYPES_ENUM.MARISA_TRIE
+      value: INDEX_TYPES_ENUM.MARISA_TRIE,
     },
   ],
 };
@@ -271,3 +271,23 @@ export enum MILVUS_DEPLOY_MODE {
   DISTRIBUTED = 'DISTRIBUTED',
   STANDALONE = 'STANDALONE',
 }
+
+export enum DataTypeStringEnum {
+  Bool = 'Bool',
+  Int8 = 'Int8',
+  Int16 = 'Int16',
+  Int32 = 'Int32',
+  Int64 = 'Int64',
+  Float = 'Float',
+  Double = 'Double',
+  String = 'String',
+  VarChar = 'VarChar',
+  JSON = 'JSON',
+  BinaryVector = 'BinaryVector',
+  FloatVector = 'FloatVector',
+}
+
+export const NONE_INDEXABLE_DATA_TYPES = [
+  DataTypeStringEnum.Bool,
+  DataTypeStringEnum.JSON,
+];

+ 5 - 1
client/src/pages/schema/IndexTypeElement.tsx

@@ -17,6 +17,7 @@ import { ChildrenStatusType } from '@/components/status/Types';
 import { sleep } from '@/utils';
 import CreateIndex from './Create';
 import { IndexState } from '../../types/Milvus';
+import { NONE_INDEXABLE_DATA_TYPES } from '@/consts';
 
 const useStyles = makeStyles((theme: Theme) => ({
   wrapper: {
@@ -206,7 +207,10 @@ const IndexTypeElement: FC<{
 
   const generateElement = () => {
     // only vector type field is able to create index
-    if (data._isPrimaryKey) {
+    if (
+      data._isPrimaryKey ||
+      NONE_INDEXABLE_DATA_TYPES.indexOf(data._fieldType) !== -1
+    ) {
       return <div className={classes.item}>--</div>;
     }
     // _indexType example: FLAT

+ 21 - 20
client/src/pages/schema/Schema.tsx

@@ -8,7 +8,6 @@ import icons from '@/components/icons/Icons';
 import { FieldHttp, IndexHttp } from '@/http';
 import { FieldView } from './Types';
 import IndexTypeElement from './IndexTypeElement';
-import { DataTypeStringEnum } from '../collections/Types';
 
 const useStyles = makeStyles((theme: Theme) => ({
   wrapper: {
@@ -164,31 +163,33 @@ const Schema: FC<{
             _indexParamElement: (
               <div className={classes.paramWrapper}>
                 {f._indexParameterPairs?.length > 0 ? (
-                  f._indexParameterPairs.map(p => (
-                    <span key={p.key} className="param">
-                      <Typography variant="body1" className="key">
-                        {`${p.key}:`}
-                      </Typography>
-                      <Typography variant="body1" className="value">
-                        {p.value}
-                      </Typography>
-                    </span>
-                  ))
+                  f._indexParameterPairs.map(p =>
+                    p.value ? (
+                      <>
+                        <span key={p.key} className="param">
+                          <Typography variant="body1" className="key">
+                            {`${p.key}:`}
+                          </Typography>
+                          <Typography variant="body1" className="value">
+                            {p.value}
+                          </Typography>
+                        </span>
+                      </>
+                    ) : (
+                      ''
+                    )
+                  )
                 ) : (
                   <>--</>
                 )}
               </div>
             ),
             _indexTypeElement: (
-              <>
-                {f._fieldType !== DataTypeStringEnum.JSON ? (
-                  <IndexTypeElement
-                    data={f}
-                    collectionName={collectionName}
-                    cb={fetchFields}
-                  />
-                ) : null}
-              </>
+              <IndexTypeElement
+                data={f}
+                collectionName={collectionName}
+                cb={fetchFields}
+              />
             ),
           })
         );