Browse Source

add default field when collection selected during vector search

tumao 3 years ago
parent
commit
438870dffb

+ 5 - 3
client/src/components/insert/Container.tsx

@@ -126,9 +126,11 @@ const InsertContainer: FC<InsertContentProps> = ({
       }));
       setPartitionOptions(partitionOptions);
 
-      // set first partition option value as default value
-      const [{ value: defaultPartitionValue }] = partitionOptions;
-      setPartitionValue(defaultPartitionValue as string);
+      if (partitionOptions.length > 0) {
+        // set first partition option value as default value
+        const [{ value: defaultPartitionValue }] = partitionOptions;
+        setPartitionValue(defaultPartitionValue as string);
+      }
     }
   }, [collectionValue]);
 

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

@@ -202,6 +202,12 @@ const VectorSearch = () => {
       // only vector type fields can be select
       const fieldOptions = getVectorFieldOptions(vectorFields, indexes);
       setFieldOptions(fieldOptions);
+      if (fieldOptions.length > 0) {
+        // set first option value as default field value
+        const [{ value: defaultFieldValue }] = fieldOptions;
+        setSelectedField(defaultFieldValue as string);
+      }
+
       // only non vector type fields can be advanced filter
       const filterFields = getNonVectorFieldsForFilter(nonVectorFields);
       setFilterFields(filterFields);