diff --git a/README.cn.md b/README.cn.md
index 6b641df..d7b2e76 100644
--- a/README.cn.md
+++ b/README.cn.md
@@ -66,14 +66,14 @@ milvus:
token: x'x'x'x
enable: true
packages:
- - io.github.javpower.milvus.demo.model
+ - com.example.entity
```
- `milvus`:定义了与Milvus服务相关的配置。
- `uri`:Milvus服务的URI,应用程序通过这个URI与Milvus服务进行通信。
- `token`:用于验证和授权的令牌(Token),确保访问Milvus服务的安全性。
- `enable`:一个布尔值,用于指示Milvus模块是否应该被启用。
- - `packages`:这些包包含了自定义注解对应的Java类。
+ - `packages`:这些包包含了自定义注解对应的Java类,你可以认为这是你自定义的实体类所在的包。
## 应用场景
diff --git a/README.md b/README.md
index 3bb0918..815f97e 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,7 @@ Core:
io.github.javpower
milvus-plus-core
- 2.4.0-SNAPSHOT
+ 2.4.0
```
@@ -40,7 +40,7 @@ Spring:
io.github.javpower
milvus-plus-boot-starter
- 2.4.0-SNAPSHOT
+ 2.4.0
```
@@ -50,7 +50,7 @@ Solon:
io.github.javpower
milvus-plus-solon-plugin
- 2.4.0-SNAPSHOT
+ 2.4.0
```
@@ -79,29 +79,29 @@ Example usage:
```java
@Data
-@MilvusCollection(name = "face_collection") // 指定Milvus集合的名称
+@MilvusCollection(name = "face_collection") // Specifies the name of the Milvus collection
public class Face {
@MilvusField(
- name = "person_id", // 字段名称
- dataType = DataType.Int64, // 数据类型为64位整数
- isPrimaryKey = true, // 标记为主键
+ name = "person_id", // Field Name
+ dataType = DataType.Int64, // Data type is 64-bit integer
+ isPrimaryKey = true // Mark as Primary Key
)
- private Long personId; // 人员的唯一标识符
+ private Long personId; // Unique identifier of the person
@MilvusField(
- name = "face_vector", // 字段名称
- dataType = DataType.FloatVector, // 数据类型为浮点型向量
- dimension = 128, // 向量维度,假设人脸特征向量的维度是128
+ name = "face_vector", // Field Name
+ dataType = DataType.FloatVector, // The data type is a floating point vector
+ dimension = 128 // Vector dimension, assuming that the dimension of the face feature vector is 128
)
@MilvusIndex(
- indexType = IndexParam.IndexType.IVF_FLAT, // 使用IVF_FLAT索引类型
- metricType = IndexParam.MetricType.L2, // 使用L2距离度量类型
- indexName = "face_index", // 索引名称
- extraParams = { // 指定额外的索引参数
- @ExtraParam(key = "nlist", value = "100") // 例如,IVF的nlist参数
+ indexType = IndexParam.IndexType.IVF_FLAT, // Using the IVF FLAT index type
+ metricType = IndexParam.MetricType.L2, // Using the L 2 Distance Metric Type
+ indexName = "face_index", // Index Name
+ extraParams = { // Specify additional index parameters
+ @ExtraParam(key = "nlist", value = "100") // For example, the nlist parameter for IVF
}
)
- private List faceVector; // 存储人脸特征的向量
+ private List faceVector; // Storing vectors of face features
}
```
```
@@ -124,50 +124,58 @@ public class ApplicationRunnerTest implements ApplicationRunner {
Face face=new Face();
List vector = new ArrayList<>();
for (int i = 0; i < 128; i++) {
- vector.add((float) (Math.random() * 100)); // 这里仅作为示例使用随机数
+ vector.add((float) (Math.random() * 100)); // Using random numbers here as an example only
}
face.setPersonId(1l);
face.setFaceVector(vector);
- //新增
+
+ // add
List faces=new ArrayList<>();
for (int i = 1; i < 10 ;i++){
Face face1=new Face();
face1.setPersonId(Long.valueOf(i));
List vector1 = new ArrayList<>();
for (int j = 0; j < 128; j++) {
- vector1.add((float) (Math.random() * 100)); // 这里仅作为示例使用随机数
+ vector1.add((float) (Math.random() * 100)); // Using random numbers here as an example only
}
face1.setFaceVector(vector1);
faces.add(face1);
}
MilvusResp insert = mapper.insert(faces.toArray(faces.toArray(new Face[0]))); log.info("insert--{}", JSONObject.toJSONString(insert));
- //id查询
+
+ // id query
MilvusResp>> query = mapper.getById(9l);
log.info("query--getById---{}", JSONObject.toJSONString(query));
- //向量查询
+
+ // VECTOR QUERY
MilvusResp>> query1 = mapper.queryWrapper()
.vector(Face::getFaceVector, vector)
.ne(Face::getPersonId, 1L)
.topK(3)
.query();
- log.info("向量查询 query--queryWrapper---{}", JSONObject.toJSONString(query1));
- //标量查询
+ log.info("VectorQuery query--queryWrapper---{}", JSONObject.toJSONString(query1));
+
+ // SCALAR QUERY
MilvusResp>> query2 = mapper.queryWrapper()
.eq(Face::getPersonId, 2L)
.limit(3)
.query();
- log.info("标量查询 query--queryWrapper---{}", JSONObject.toJSONString(query2));
- //更新
+ log.info("ScalarQuery query--queryWrapper---{}", JSONObject.toJSONString(query2));
+
+ // update
vector.clear();
for (int i = 0; i < 128; i++) {
- vector.add((float) (Math.random() * 100)); // 这里仅作为示例使用随机数
+ vector.add((float) (Math.random() * 100)); // Using random numbers here as an example only
}
MilvusResp update = mapper.updateById(face);log.info("update--{}", JSONObject.toJSONString(update));
- //id查询
+
+ // id Query
MilvusResp>> query3 = mapper.getById(1L);log.info("query--getById---{}", JSONObject.toJSONString(query3));
- //删除
+
+ // del
MilvusResp remove = mapper.removeById(1L);log.info("remove--{}", JSONObject.toJSONString(remove));
- //查询
+
+ // query
MilvusResp>> query4 = mapper.getById(1L);log.info("query--{}", JSONObject.toJSONString(query4));
}
diff --git a/milvus-plus-boot-starter/src/main/java/org/dromara/milvus/plus/entity/MilvusProperties.java b/milvus-plus-boot-starter/src/main/java/org/dromara/milvus/plus/entity/MilvusProperties.java
index 2f42366..62a7f8b 100644
--- a/milvus-plus-boot-starter/src/main/java/org/dromara/milvus/plus/entity/MilvusProperties.java
+++ b/milvus-plus-boot-starter/src/main/java/org/dromara/milvus/plus/entity/MilvusProperties.java
@@ -15,6 +15,9 @@ import java.util.List;
public class MilvusProperties {
private boolean enable;
private String uri;
+ private String dbName;
+ private String username;
+ private String password;
private String token;
private List packages;
}
\ No newline at end of file
diff --git a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/model/MilvusProperties.java b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/model/MilvusProperties.java
index bb62979..b276dc9 100644
--- a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/model/MilvusProperties.java
+++ b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/model/MilvusProperties.java
@@ -11,6 +11,9 @@ import java.util.List;
public class MilvusProperties {
private boolean enable;
private String uri;
+ private String dbName;
+ private String username;
+ private String password;
private String token;
private List packages;
}
\ No newline at end of file
diff --git a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/service/AbstractMilvusClientBuilder.java b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/service/AbstractMilvusClientBuilder.java
index ae38b00..42642ca 100644
--- a/milvus-plus-core/src/main/java/org/dromara/milvus/plus/service/AbstractMilvusClientBuilder.java
+++ b/milvus-plus-core/src/main/java/org/dromara/milvus/plus/service/AbstractMilvusClientBuilder.java
@@ -38,6 +38,9 @@ public abstract class AbstractMilvusClientBuilder implements MilvusClientBuilder
ConnectConfig connectConfig = ConnectConfig.builder()
.uri(properties.getUri())
.token(properties.getToken())
+ .dbName(properties.getDbName())
+ .username(properties.getUsername())
+ .password(properties.getPassword())
.build();
client = new MilvusClientV2(connectConfig);
// 初始化逻辑
diff --git a/milvus-plus-solon-plugin/src/main/java/org/dromara/solon/entity/MilvusProperties.java b/milvus-plus-solon-plugin/src/main/java/org/dromara/solon/entity/MilvusProperties.java
index e53627a..64c7059 100644
--- a/milvus-plus-solon-plugin/src/main/java/org/dromara/solon/entity/MilvusProperties.java
+++ b/milvus-plus-solon-plugin/src/main/java/org/dromara/solon/entity/MilvusProperties.java
@@ -15,6 +15,9 @@ import java.util.List;
public class MilvusProperties {
private boolean enable;
private String uri;
+ private String dbName;
+ private String username;
+ private String password;
private String token;
private List packages;
}
\ No newline at end of file