Package io.milvus.param.collection
Class FieldType.Builder
java.lang.Object
io.milvus.param.collection.FieldType.Builder
- Enclosing class:
FieldType
Builder for
FieldType class.-
Method Summary
Modifier and TypeMethodDescriptionaddTypeParam(@NonNull String key, @NonNull String value) Adds a parameter pair for the field.build()Verifies parameters and creates a newFieldTypeinstance.withAutoID(boolean autoID) Enables auto-id function for the field.withClusteringKey(boolean clusteringKey) Set the field to be a clustering key.withDataType(@NonNull DataType dataType) Sets the data type for the field.withDefaultValue(Object obj) Sets default value of this field.withDescription(@NonNull String description) Sets the field description.withDimension(@NonNull Integer dimension) Sets the dimension of a vector field.withElementType(@NonNull DataType elementType) Sets the element type for Array type field.withIsDynamic(boolean isDynamic) Sets the isDynamic of a field.withMaxCapacity(@NonNull Integer maxCapacity) Sets the max capacity of an array field.withMaxLength(@NonNull Integer maxLength) Sets the max length of a varchar field.withNullable(boolean nullable) Sets this field is nullable or not.withPartitionKey(boolean partitionKey) Sets the field to be partition key.withPrimaryKey(boolean primaryKey) Sets the field as the primary key field.withTypeParams(@NonNull Map<String, String> typeParams) Sets more parameters for the field.
-
Method Details
-
withName
-
withIsDynamic
Sets the isDynamic of a field.- Parameters:
isDynamic- of a field- Returns:
Builder
-
withPrimaryKey
Sets the field as the primary key field. Note that the current release of Milvus only supportLongdata type as primary key.- Parameters:
primaryKey- true is primary key, false is not- Returns:
Builder
-
withDescription
Sets the field description. The description can be empty. The default is "".- Parameters:
description- description of the field- Returns:
Builder
-
withDataType
Sets the data type for the field.- Parameters:
dataType- data type of the field- Returns:
Builder
-
withElementType
Sets the element type for Array type field.- Parameters:
elementType- element type of the Array type field- Returns:
Builder
-
addTypeParam
Adds a parameter pair for the field.- Parameters:
key- parameter keyvalue- parameter value- Returns:
Builder
-
withTypeParams
Sets more parameters for the field.- Parameters:
typeParams- parameters of the field- Returns:
Builder
-
withDimension
Sets the dimension of a vector field. Dimension value must be greater than zero.- Parameters:
dimension- dimension of the field- Returns:
Builder
-
withMaxLength
Sets the max length of a varchar field. The value must be greater than zero.- Parameters:
maxLength- max length of a varchar field- Returns:
Builder
-
withMaxCapacity
Sets the max capacity of an array field. The value must be greater than zero. The valid capacity value range is [1, 4096]- Parameters:
maxCapacity- max capacity of an array field- Returns:
Builder
-
withAutoID
Enables auto-id function for the field. Note that the auto-id function can only be enabled on primary key field. If auto-id function is enabled, Milvus will automatically generate unique ID for each entity, thus you do not need to provide values for the primary key field when inserting. If auto-id is disabled, you need to provide values for the primary key field when inserting.- Parameters:
autoID- true enable auto-id, false disable auto-id- Returns:
Builder
-
withPartitionKey
Sets the field to be partition key. A partition key field's values are hashed and distributed to different logic partitions. Only int64 and varchar type field can be partition key. Primary key field cannot be partition key.- Parameters:
partitionKey- true is partition key, false is not- Returns:
Builder
-
withNullable
Sets this field is nullable or not. Primary key field, vector fields, Array fields cannot be nullable. 1. if the field is nullable, user can input JsonNull/JsonObject(for row-based insert), or input null/object(for column-based insert) 1) if user input JsonNull, this value is replaced by default value 2) if user input JsonObject, infer this value by type 2. if the field is not nullable, user can input JsonNull/JsonObject(for row-based insert), or input null/object(for column-based insert) 1) if user input JsonNull, and default value is null, throw error 2) if user input JsonNull, and default value is not null, this value is replaced by default value 3) if user input JsonObject, infer this value by type- Parameters:
nullable- true is nullable, false is not- Returns:
Builder
-
withDefaultValue
Sets default value of this field. If nullable is false, the default value cannot be null. If nullable is true, the default value can be null. Only scalar fields(not include Array field) support default value. The default value type must obey the following rule: - Boolean for Bool fields - Short for Int8/Int16 fields - Short/Integer for Int32 fields - Short/Integer/Long for Int64 fields - Float for Float fields - Double for Double fields - String for Varchar fields - JsonObject for JSON fields For JSON field, you can use JsonNull.INSTANCE as default value. For other scalar fields, you can use null as default value.- Parameters:
obj- the default value- Returns:
Builder
-
withClusteringKey
Set the field to be a clustering key. A clustering key can notify milvus to trigger a clustering compaction to redistribute entities among segments in a collection based on the values in the clustering key field. And one global index called PartitionStats is generated to store the mapping relationship between segments and clustering key values. Once receiving a search/query request that carries a clustering key value, it quickly finds out a search scope from the PartitionStats which significantly improving search performance. Only scalar fields(except Array/JSON) can be clustering key. Only one clustering key is allowed in one collection.- Parameters:
clusteringKey- true is clustering key, false is not- Returns:
Builder
-
build
Verifies parameters and creates a newFieldTypeinstance.- Returns:
FieldType- Throws:
ParamException
-