From 4a2c17bcf2b975ecc1bbb84fd4440e92da09eb65 Mon Sep 17 00:00:00 2001 From: xgc Date: Fri, 30 Aug 2024 16:32:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?add<=E7=A6=81=E7=94=A8=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=AD=97=E6=AE=B5>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../milvus/plus/annotation/MilvusCollection.java | 12 +++++++++++- .../milvus/plus/builder/CollectionSchemaBuilder.java | 10 +++++++++- .../milvus/plus/converter/MilvusConverter.java | 4 +++- .../org/dromara/milvus/plus/model/MilvusEntity.java | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/annotation/MilvusCollection.java b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/annotation/MilvusCollection.java index f5d1d01..4dded39 100644 --- a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/annotation/MilvusCollection.java +++ b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/annotation/MilvusCollection.java @@ -20,9 +20,19 @@ public @interface MilvusCollection { String name(); /** - * + * 别名 */ String[] alias() default {}; + /** + * 一致性级别 + */ + ConsistencyLevel level() default ConsistencyLevel.BOUNDED; + + /** + * 禁用动态字段 + */ + boolean enableDynamicField() default false; + } \ No newline at end of file diff --git a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/builder/CollectionSchemaBuilder.java b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/builder/CollectionSchemaBuilder.java index 348aea0..2c23551 100644 --- a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/builder/CollectionSchemaBuilder.java +++ b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/builder/CollectionSchemaBuilder.java @@ -16,7 +16,14 @@ public class CollectionSchemaBuilder { private final MilvusClientV2 wrapper; private final CreateCollectionReq.CollectionSchema schema; private ConsistencyLevel consistencyLevel=ConsistencyLevel.BOUNDED; + private Boolean enableDynamicField=false; + public CollectionSchemaBuilder(Boolean enableDynamicField,String collectionName, MilvusClientV2 wrapper) { + this.collectionName = collectionName; + this.wrapper = wrapper; + this.schema = wrapper.createSchema(); + this.enableDynamicField=enableDynamicField; + } public CollectionSchemaBuilder(String collectionName, MilvusClientV2 wrapper) { this.collectionName = collectionName; this.wrapper = wrapper; @@ -44,7 +51,8 @@ public class CollectionSchemaBuilder { CreateCollectionReq req=CreateCollectionReq.builder(). collectionName(this.collectionName). collectionSchema(this.schema). - consistencyLevel(this.consistencyLevel) + consistencyLevel(this.consistencyLevel). + enableDynamicField(this.enableDynamicField) .build(); wrapper.createCollection(req); } diff --git a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/converter/MilvusConverter.java b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/converter/MilvusConverter.java index 5566efb..7d6c027 100644 --- a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/converter/MilvusConverter.java +++ b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/converter/MilvusConverter.java @@ -69,6 +69,8 @@ public class MilvusConverter { // 集合名称 String collectionName = collectionAnnotation.name(); milvus.setCollectionName(collectionName); + boolean enableDynamicField = collectionAnnotation.enableDynamicField(); + milvus.setEnableDynamicField(enableDynamicField); //一致性级别 ConsistencyLevel level = collectionAnnotation.level(); milvus.setConsistencyLevel(level); @@ -220,7 +222,7 @@ public class MilvusConverter { } // 创建新集合 CollectionSchemaBuilder schemaBuilder = new CollectionSchemaBuilder( - milvusEntity.getCollectionName(), client + milvusEntity.getEnableDynamicField(),milvusEntity.getCollectionName(), client ); schemaBuilder.addField(milvusEntity.getMilvusFields().toArray(new AddFieldReq[0])); schemaBuilder.addConsistencyLevel(milvusEntity.getConsistencyLevel()); diff --git a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/model/MilvusEntity.java b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/model/MilvusEntity.java index 0011fd4..2ee7ad1 100644 --- a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/model/MilvusEntity.java +++ b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/model/MilvusEntity.java @@ -18,4 +18,5 @@ public class MilvusEntity { private List milvusFields; private List partitionName; private ConsistencyLevel consistencyLevel; + private Boolean enableDynamicField; } From 6cc5dcbedcfd1b974f998122b15ada9916a8594a Mon Sep 17 00:00:00 2001 From: xgc Date: Fri, 30 Aug 2024 16:39:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8F=91=E5=B8=83=202.1.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.cn.md | 6 +++--- README.md | 6 +++--- milvus-plus-parent/pom.xml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.cn.md b/README.cn.md index c5ee54a..cd61384 100644 --- a/README.cn.md +++ b/README.cn.md @@ -31,7 +31,7 @@ org.dromara milvus-plus-core - 2.1.3 + 2.1.4 ``` @@ -41,7 +41,7 @@ Spring应用支持: org.dromara milvus-plus-boot-starter - 2.1.3 + 2.1.4 ``` @@ -51,7 +51,7 @@ Solon应用支持: org.dromara milvus-plus-solon-plugin - 2.1.3 + 2.1.4 ``` diff --git a/README.md b/README.md index 7f6c8fe..4490a6d 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Custom extension support: org.dromara milvus-plus-core - 2.1.3 + 2.1.4 ``` @@ -37,7 +37,7 @@ Spring application support: org.dromara milvus-plus-boot-starter - 2.1.3 + 2.1.4 ``` @@ -47,7 +47,7 @@ Solon application support: org.dromara milvus-plus-solon-plugin - 2.1.3 + 2.1.4 ``` diff --git a/milvus-plus-parent/pom.xml b/milvus-plus-parent/pom.xml index 3d4c762..f4cc5c6 100644 --- a/milvus-plus-parent/pom.xml +++ b/milvus-plus-parent/pom.xml @@ -30,7 +30,7 @@ - 2.1.3 + 2.1.4 ${java.version} ${java.version} 3.11.0