Browse Source

fix: index parameters not shown if it was created by newer sdk (#792)

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 3 months ago
parent
commit
46b5f299a4

+ 3 - 3
client/src/pages/databases/collections/schema/Schema.tsx

@@ -18,7 +18,7 @@ import RenameCollectionDialog from '@/pages/dialogs/RenameCollectionDialog';
 import CopyButton from '@/components/advancedSearch/CopyButton';
 import RefreshButton from '@/components/customButton/RefreshButton';
 import { CollectionService } from '@/http';
-import type { FieldObject } from '@server/types';
+import type { FieldObject, KeyValuePair } from '@server/types';
 
 const Overview = () => {
   const { fetchCollection, collections, loading, database } =
@@ -215,7 +215,7 @@ const Overview = () => {
             {f.index.indexParameterPairs.length > 0 ? (
               f.index.indexParameterPairs.map((p: any) =>
                 p.value ? (
-                  <span key={p.key + p.value}>
+                  <div key={p.key + p.value}>
                     <span className="param">
                       <Typography variant="body1" className="key">
                         {`${p.key}:`}
@@ -224,7 +224,7 @@ const Overview = () => {
                         {p.value}
                       </Typography>
                     </span>
-                  </span>
+                  </div>
                 ) : (
                   ''
                 )

+ 7 - 1
server/src/collections/collections.service.ts

@@ -780,13 +780,19 @@ export class CollectionsService {
       const metricTypePair =
         index.params.filter(v => v.key === 'metric_type') || [];
       index.metricType = findKeyValue(metricTypePair, 'metric_type') as string;
+
+      // copy index.params withouth index_type and metric_type and params
+      const indexParams = index.params.filter(
+        p => p.key !== 'index_type' && p.key !== 'metric_type' && p.key !== 'params'
+      );
       // get index parameter pairs
       const paramsJSONstring = findKeyValue(index.params, 'params'); // params is a json string
       const params =
         (paramsJSONstring &&
           getKeyValueListFromJsonString(paramsJSONstring as string)) ||
         [];
-      index.indexParameterPairs = [...metricTypePair, ...params];
+
+      index.indexParameterPairs = [...metricTypePair, ...indexParams, ...params];
     });
 
     // Return the response from the Milvus SDK's describeIndex function