Closed Yiling1f closed 1 month ago
List<FieldType> fieldsSchema = Arrays.asList(
FieldType.newBuilder()
.withName("id")
.withDataType(DataType.Int64)
.withPrimaryKey(true)
.withAutoID(false)
.build(),
FieldType.newBuilder()
.withName("vector")
.withDataType(DataType.FloatVector)
.withDimension(128)
.build(),
FieldType.newBuilder()
.withName("title")
.withDataType(DataType.Array)
.withMaxCapacity(100)
.withElementType(DataType.VarChar)
.withMaxLength(64)
.build()
);
// Create the collection with 3 fields
R<RpcStatus> ret = milvusClient.createCollection(CreateCollectionParam.newBuilder()
.withCollectionName(COLLECTION_NAME)
.withFieldTypes(fieldsSchema)
.build());
if (ret.getStatus() != R.Status.Success.getCode()) {
throw new RuntimeException("Failed to create collection! Error: " + ret.getMessage());
}
R<DescribeCollectionResponse> response = milvusClient.describeCollection(DescribeCollectionParam.newBuilder()
.withCollectionName(COLLECTION_NAME)
.build());
CommonUtils.handleResponseStatus(response);
DescCollResponseWrapper wrapper = new DescCollResponseWrapper(response.getData());
FieldType fieldType = wrapper.getFieldByName("title");
System.out.println(fieldType.getDataType());
System.out.println(fieldType.getElementType());
Output:
Array
VarChar
Thanks for response! My question has been resolved.
Issue Description In Milvus SDK 2.4.x, when defining a field with Array data type (e.g., Array), the FieldSchema does not provide direct access to the element_type information. This issue limits the ability to retrieve the full type specification (e.g., Array) programmatically, as only the base type Array is returned by field.getDataType().name().
Steps to Reproduce
Expected Behavior The FieldSchema for Array data types should include the element_type (e.g., Int32) as part of typeParamsList or another accessible attribute, allowing users to retrieve the specific array type programmatically.