Skip to main content

Type Support

The table recommends Java property types for Milvus fields. Vector types and dimensions follow the collection schema. See Java/JDBC types.

Type Mappings

Vector field usage is described under Vector Types.

Vector rows also list JDBC read and write forms.

Milvus field typeJava typeDescription
BOOLBooleanUse Boolean semantics, not a general integer property.
INT8ByteSigned 8-bit integer.
INT16ShortSigned 16-bit integer.
INT32IntegerSigned 32-bit integer.
INT64LongSigned 64-bit integer.
FLOATFloat32-bit floating-point value.
DOUBLEDouble64-bit floating-point value.
VARCHAR(max_length)Stringmax_length limits content by UTF-8 byte length.
JSONMap / List / BeanSee JSON Field Mapping; direct getObject() returns JsonElement.
ARRAY<BOOL>(max_capacity)Boolean[]Boolean elements.
ARRAY<INT8>(max_capacity)Byte[]Signed 8-bit integer elements.
ARRAY<INT16>(max_capacity)Short[]Signed 16-bit integer elements.
ARRAY<INT32>(max_capacity)Integer[]Signed 32-bit integer elements.
ARRAY<INT64>(max_capacity)Long[]Signed 64-bit integer elements.
ARRAY<FLOAT>(max_capacity)Float[]32-bit floating-point elements.
ARRAY<DOUBLE>(max_capacity)Double[]64-bit floating-point elements.
ARRAY<VARCHAR(max_length)>(max_capacity)String[]max_length limits each string; max_capacity limits the element count.
FLOAT_VECTOR(n)List<Float>getObject() returns List<Float>. Writes accept a numeric List or one-dimensional numeric primitive array and convert every element to Float; length must be n.
BINARY_VECTOR(n)byte[]getBytes() returns bit-packed bytes with length n/8. Writes accept byte[], ByteBuffer, or a List of byte values; this is not an arbitrary-length BLOB.
FLOAT16_VECTOR(n)byte[]Queries return two little-endian half-precision bytes per dimension; writes also accept a numeric List or numeric primitive array.
BFLOAT16_VECTOR(n)byte[]Queries return two little-endian BFloat16 bytes per dimension; writes also accept a numeric List or numeric primitive array.
INT8_VECTOR(n)byte[]getBytes() returns one signed byte per dimension. Writes also accept ByteBuffer, a numeric List, or a one-dimensional numeric primitive array; elements must be integers from -128 through 127 and length must be n.
SPARSE_FLOAT_VECTORSortedMap<Long, Float>getObject() returns dimensions in ascending index order. Writes accept a nonempty Map<Number, Number> whose keys are dimension indices and values are finite floating-point weights.

The target field schema determines what a byte[] means. It is a sequence of signed numeric elements for FLOAT_VECTOR, a packed encoding for BINARY_VECTOR, FLOAT16_VECTOR, and BFLOAT16_VECTOR, and one vector component per byte for INT8_VECTOR. The driver does not guess the vector kind from the Java parameter type alone.

Vector Types

See Vector Operations for field mapping and reads/writes.

Array Types

Array fields accept populated and empty arrays. Declaring the field NULL also allows the entire field to be null. For example, new Integer[0] stores an empty array, which is distinct from a null field value.

Individual array elements cannot be null, so new Integer[] { 1, null } cannot be written to an ARRAY<INT32> field.

Example: Array, JSON and Float Vector

CREATE TABLE type_example (
id INT64 PRIMARY KEY,
profile JSON NULL,
tags `ARRAY<INT32>`(10) NULL,
embedding FLOAT_VECTOR(3)
) WITH (consistency_level=Strong);
CREATE INDEX type_embedding ON type_example(embedding) USING AUTOINDEX WITH (metric_type=L2);
LOAD TABLE type_example;

Given an established Connection conn:

import java.sql.Array;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;

Array tags = conn.createArrayOf("INTEGER", new Integer[] { 1, 2 });
try (PreparedStatement ps = conn.prepareStatement(
"INSERT INTO type_example (id, profile, tags, embedding) VALUES (?, ?, ?, ?)")) {
ps.setLong(1, 1L);
ps.setString(2, "{\"city\":\"Hangzhou\"}");
ps.setArray(3, tags);
ps.setObject(4, List.of(0.1f, 0.2f, 0.3f));
ps.executeUpdate();
} finally {
tags.free();
}
try (PreparedStatement ps = conn.prepareStatement(
"SELECT profile, tags, embedding FROM type_example WHERE id = ?")) {
ps.setLong(1, 1L);
try (ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
Object profile = rs.getObject("profile");
Array loadedTags = rs.getArray("tags");
try {
Object values = loadedTags.getArray();
} finally {
loadedTags.free();
}
Object embedding = rs.getObject("embedding");
}
}
}

Vector representation and dimension restrictions are detailed in SQL types. BinaryVector is not a general BLOB column.

Reading a Year and Month from Date Text

When a VARCHAR stores a complete date such as 2024-03-01, explicitly select the conversion to YearMonth. A complete date is not year-month text in the 2024-03 format.

import java.time.YearMonth;
import net.hasor.dbvisitor.types.handler.time.SqlTimestampAsYearMonthTypeHandler;

SqlTimestampAsYearMonthTypeHandler handler = new SqlTimestampAsYearMonthTypeHandler();
YearMonth month = jdbcTemplate.queryForObject(
"SELECT date_value FROM event_info WHERE id = ?",
new Object[] { id }, (rs, rowNum) -> handler.getResult(rs, 1));
// month is 2024-03.

For property mapping configuration, see Basic Type Handlers.

Limits

  • Writing BigDecimal to DOUBLE loses precision; INT64 covers only signed 64-bit integers.
  • Dates and times use VARCHAR or INT64; Milvus has no native date type.
  • Milvus has no general BLOB or VARBINARY; BinaryVector stores only fixed-dimension bit vectors.

Entity Mapping

An entity must match an existing collection, including its single primary key. Field renaming and type conversion do not create fields or change their Milvus types.

Map Java enums to VARCHAR names/codes or INT32 numeric codes; see Enum Mapping. Milvus does not provide an ENUM field type.

An ARRAY<INT32> field can map to Integer[]; its element type, capacity and nullability still apply. For Bean or Map properties stored as JSON, see JSON Field Mapping. JSON text stored in VARCHAR does not acquire native JSON filtering.