Skip to content

Commit

Permalink
Merge pull request #307 from zilliztech/attu-305
Browse files Browse the repository at this point in the history
hide create index button if the data type is none-indexable
  • Loading branch information
shanghaikid authored Nov 7, 2023
2 parents 605ace7 + d692b85 commit f259d1f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 22 deletions.
22 changes: 21 additions & 1 deletion client/src/consts/Milvus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
],
};
Expand Down Expand Up @@ -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,
];
6 changes: 5 additions & 1 deletion client/src/pages/schema/IndexTypeElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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
Expand Down
41 changes: 21 additions & 20 deletions client/src/pages/schema/Schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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}
/>
),
})
);
Expand Down

0 comments on commit f259d1f

Please sign in to comment.