### Java Example for MilvusPlus searchParams Configuration Source: https://github.com/dromara/milvusplus/blob/main/README.cn.md Demonstrates how to configure `searchParams` using a `HashMap` in Java for Milvus search operations, specifying `metric_type`, `radius`, and `range_filter` as key-value pairs. ```Java Map searchParams = new HashMap<>(); searchParams.put("metric_type", "L2"); searchParams.put("radius", 0.5f); searchParams.put("range_filter", 0.3f); ``` -------------------------------- ### Example of Setting Milvus Search Parameters in Java Source: https://github.com/dromara/milvusplus/blob/main/README.md Demonstrates how to construct a `HashMap` to define search parameters for Milvus queries, including `metric_type`, `radius`, and `range_filter`. This map is typically passed to the `searchParams` method of a query builder. ```Java Map searchParams = new HashMap<>(); searchParams.put("metric_type", "L2"); searchParams.put("radius", 0.5f); searchParams.put("range_filter", 0.3f); ``` -------------------------------- ### Combine Text Matching and Vector Search in MilvusPlus (Java) Source: https://github.com/dromara/milvusplus/blob/main/Tantivy文本匹配.md This Java example illustrates how to perform a combined search using both vector similarity and text matching in MilvusPlus. The `textMatch` method filters results based on keyword presence, which can be used in conjunction with `textVector` to refine search scope and improve query performance. ```java MilvusResp>> xx = mapper .queryWrapper() .textVector(Face::getText, "whats the focus of information retrieval?") .textMatch(Face::getText,"retrieval") .textMatch(Face::getText,"information") .topK(2) .query(); ``` -------------------------------- ### MilvusPlus Java Collection Definition and CRUD Operations Source: https://github.com/dromara/milvusplus/blob/main/README.cn.md This example illustrates how to define a Milvus collection using Java annotations (`@MilvusCollection`, `@MilvusField`, `@MilvusIndex`) for schema mapping. It then demonstrates a complete set of CRUD operations (insert, query by ID, vector search, scalar search, update, and delete) on the defined Milvus collection using the `MilvusMapper` interface. ```Java @Data @MilvusCollection(name = "face_collection") // Specify the name of the Milvus collection public class Face { @MilvusField( name = "person_id", // Field name dataType = DataType.Int64, // Data type is 64-bit integer isPrimaryKey = true // Mark as primary key ) private Long personId; // Unique identifier for the person @MilvusField( name = "face_vector", // Field name dataType = DataType.FloatVector, // Data type is float vector dimension = 128 // Vector dimension, assuming face feature vector dimension is 128 ) @MilvusIndex( indexType = IndexParam.IndexType.IVF_FLAT, // Use IVF_FLAT index type metricType = IndexParam.MetricType.L2, // Use L2 distance metric type indexName = "face_index", // Index name extraParams = { // Specify additional index parameters @ExtraParam(key = "nlist", value = "100") // For example, IVF's nlist parameter } ) private List faceVector; // Vector storing face features } @Component public class FaceMilvusMapper extends MilvusMapper { } @Component @Slf4j public class ApplicationRunnerTest implements ApplicationRunner { private final FaceMilvusMapper mapper; public ApplicationRunnerTest(FaceMilvusMapper mapper) { this.mapper = mapper; } @Override public void run(ApplicationArguments args){ Face face=new Face(); List vector = new ArrayList<>(); for (int i = 0; i < 128; i++) { vector.add((float) (Math.random() * 100)); // Here, random numbers are used as an example } face.setPersonId(1l); face.setFaceVector(vector); // Add new 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)); // Here, random numbers are used as an example } face1.setFaceVector(vector1); faces.add(face1); } MilvusResp insert = mapper.insert(faces.toArray(faces.toArray(new Face[0]))); log.info("insert--{}", JSONObject.toJSONString(insert)); // Query by ID 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("Vector query query--queryWrapper---", JSONObject.toJSONString(query1)); // Scalar query MilvusResp>> query2 = mapper.queryWrapper() .eq(Face::getPersonId, 2L) .limit(3) .query(); log.info("Scalar query query--queryWrapper---", JSONObject.toJSONString(query2)); // Update vector.clear(); for (int i = 0; i < 128; i++) { vector.add((float) (Math.random() * 100)); // Here, random numbers are used as an example } MilvusResp update = mapper.updateById(face);log.info("update--{}", JSONObject.toJSONString(update)); // Query by ID MilvusResp>> query3 = mapper.getById(1L);log.info("query--getById---", JSONObject.toJSONString(query3)); // Delete MilvusResp remove = mapper.removeById(1L);log.info("remove--{}", JSONObject.toJSONString(remove)); // Query MilvusResp>> query4 = mapper.getById(1L);log.info("query--{}", JSONObject.toJSONString(query4)); } } ``` -------------------------------- ### Milvus Index and Metric Types Reference Source: https://github.com/dromara/milvusplus/blob/main/README.cn.md Comprehensive documentation of Milvus index types and metric types supported by MilvusPlus. This section explains their purpose, applicability, and trade-offs for various data scales and search requirements, guiding users in selecting the optimal configuration for their vector database. ```APIDOC IndexType (索引类型): - INVALID: Invalid index type, for internal marking only. - FLAT: Brute-force search, suitable for small datasets. - IVF_FLAT: Inverted file index (flat mode), suitable for medium-sized datasets. - IVF_SQ8: Inverted file index (quantized mode), suitable for large datasets, sacrifices precision for speed. - IVF_PQ: Inverted file index (product quantization mode), suitable for large, high-dimensional datasets, balances speed and precision. - HNSW: Hierarchical Navigable Small World graph, provides fast search, suitable for large datasets. - DISKANN: Disk-based Approximate Nearest Neighbor search, suitable for large datasets stored on disk. - AUTOINDEX: Automatically selects the optimal index type. - SCANN: Uses scanning and tree structures to accelerate search. - GPU_IVF_FLAT, GPU_IVF_PQ: GPU accelerated indexes, for GPU environments. - BIN_FLAT, BIN_IVF_FLAT: Binary vector specific indexes. - TRIE: Trie index, suitable for string types. - STL_SORT: Sort index, suitable for scalar fields. MetricType (度量类型): - INVALID: Invalid metric type, for internal marking only. - L2: Euclidean distance, suitable for floating-point vectors. - IP: Inner product, used for calculating cosine similarity. - COSINE: Cosine similarity, suitable for text and image search. - HAMMING: Hamming distance, suitable for binary vectors. - JACCARD: Jaccard similarity coefficient, suitable for set similarity calculation. ``` -------------------------------- ### MilvusPlus Java Entity Definition and CRUD Operations Source: https://github.com/dromara/milvusplus/blob/main/README.md This example demonstrates how to define a Milvus collection entity using annotations (`@MilvusCollection`, `@MilvusField`, `@MilvusIndex`) and perform various data manipulation operations (insert, query by ID, vector query, scalar query, update, delete) using the `MilvusMapper` within a Spring Boot application context. It covers setting up primary keys, vector fields with dimensions, and index parameters. ```java @Data @MilvusCollection(name = "face_collection") // Specifies the name of the Milvus collection public class Face { @MilvusField( name = "person_id", // Field Name dataType = DataType.Int64, // Data type is 64-bit integer isPrimaryKey = true // Mark as Primary Key ) private Long personId; // Unique identifier of the person @MilvusField( 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, // 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; // Storing vectors of face features } ``` ```java @Component public class FaceMilvusMapper extends MilvusMapper { } @Component @Slf4j public class ApplicationRunnerTest implements ApplicationRunner { private final FaceMilvusMapper mapper; public ApplicationRunnerTest(FaceMilvusMapper mapper) { this.mapper = mapper; } @Override public void run(ApplicationArguments args){ Face face=new Face(); List vector = new ArrayList<>(); for (int i = 0; i < 128; i++) { 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)); // 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 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("VectorQuery query--queryWrapper---", JSONObject.toJSONString(query1)); // SCALAR QUERY MilvusResp>> query2 = mapper.queryWrapper() .eq(Face::getPersonId, 2L) .limit(3) .query(); log.info("ScalarQuery query--queryWrapper---", JSONObject.toJSONString(query2)); // update vector.clear(); for (int i = 0; i < 128; i++) { 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 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)); } } ``` -------------------------------- ### MilvusPlus Core Data Operations API Source: https://github.com/dromara/milvusplus/blob/main/README.cn.md API methods for performing basic CRUD operations (get, remove, update, insert) on Milvus data using MilvusPlus. These methods provide a high-level interface for common data management tasks. ```APIDOC getById(Serializable ... ids) - 功能: 根据提供的ID列表查询数据。 - 参数: - ids: 一个可序列化的ID列表。 - 返回: MilvusResp>> - 包含查询结果的响应。 removeById(Serializable ... ids) - 功能: 根据提供的ID列表删除数据。 - 参数: - ids: 一个可序列化的ID列表。 - 返回: MilvusResp - 删除操作的响应。 updateById(T ... entity) - 功能: 根据提供的实体更新数据。 - 参数: - entity: 一个实体对象列表。 - 返回: MilvusResp - 更新操作的响应。 insert(T ... entity) - 功能: 插入提供的实体到数据库。 - 参数: - entity: 一个实体对象列表。 - 返回: MilvusResp - 插入操作的响应。 lambda(Wrapper wrapper) - 功能: 初始化并返回通用构建器实例。 ``` -------------------------------- ### LambdaQueryWrapper Class API Reference Source: https://github.com/dromara/milvusplus/blob/main/README.md API documentation for the `LambdaQueryWrapper` class, used to construct and execute Milvus search queries. It details constructors, methods for setting partition, search, and result parameters. ```APIDOC LambdaQueryWrapper Constructors: - LambdaQueryWrapper(): No-argument constructor. - LambdaQueryWrapper(String collectionName, MilvusClientV2 client, ConversionCache conversionCache, Class entityType): Constructor that initializes the collection name, Milvus client, type conversion cache, and entity type. Partition Settings: - partition(String ... partitionName): Adds one or more partition names to the query. - partition(FieldFunction... partitionName): Adds partition names based on the provided field functions. Search Parameter Settings: - searchParams(Map searchParams): Sets search parameters. - metric_type Type: String Description: Specifies the metric type used for the search operation. It must be consistent with the metric type used when indexing vector fields. Optional values: L2, IP, COSINE Example: searchParams.put("metric_type", "L2"); - radius Type: float Description: Sets the minimum similarity threshold for the search operation. When metric_type is set to L2, this value should be greater than range_filter; otherwise, it should be less than range_filter. Example: searchParams.put("radius", 0.5f); - range_filter Type: float Description: Limits the similarity range of the search operation. When metric_type is set to IP or COSINE, this value should be greater than radius; otherwise, it should be less than radius. Example: searchParams.put("range_filter", 0.3f); - radius(Object radius): Sets the search radius. - rangeFilter(Object rangeFilter): Sets the range filter. - metricType(Object metric_type): Sets the metric type. Result Settings: - outputFields(List outputFields): Sets the fields to be returned. - roundDecimal(int roundDecimal): Sets the number of decimal places for the returned distance values. ``` -------------------------------- ### MilvusPlus LambdaQueryWrapper API for Milvus Search Source: https://github.com/dromara/milvusplus/blob/main/README.cn.md Comprehensive API documentation for `LambdaQueryWrapper`, a builder class used to construct and execute complex search queries against Milvus. It covers constructors, partition settings, search parameters, result settings, various query conditions, JSON/array operations, logical operations, vector search, and query execution. ```APIDOC LambdaQueryWrapper Class Documentation Constructors: - LambdaQueryWrapper(): 无参构造函数。 - LambdaQueryWrapper(String collectionName, MilvusClientV2 client, ConversionCache conversionCache, Class entityType): 构造函数,初始化集合名称、Milvus 客户端、类型转换缓存和实体类型。 Partition Settings: - partition(String ... partitionName): 添加一个或多个分区名称到查询中。 - partition(FieldFunction... partitionName): 根据提供的字段函数添加分区名称。 Search Parameter Settings: - searchParams(Map searchParams): 设置搜索参数。 - metric_type (String): 指定搜索操作使用的度量类型。必须与索引向量字段时使用的度量类型一致。 - 可选值: L2 (欧几里得距离), IP (内积), COSINE (余弦相似度)。 - radius (float): 设置搜索操作的最小相似度阈值。当 metric_type 设置为 L2 时,此值应大于 range_filter;否则,应小于 range_filter。 - range_filter (float): 限定搜索操作的相似度范围。当 metric_type 设置为 IP 或 COSINE 时,此值应大于 radius;否则,应小于 radius。 - radius(Object radius): 设置搜索半径。 - rangeFilter(Object rangeFilter): 设置范围过滤器。 - metricType(Object metric_type): 设置度量类型。 Result Settings: - outputFields(List outputFields): 设置要返回的字段。 - roundDecimal(int roundDecimal): 设置返回的距离值的小数位数。 Query Condition Building: - eq(String fieldName, Object value): 添加等于条件。 - ne(String fieldName, Object value): 添加不等于条件。 - gt(String fieldName, Object value): 添加大于条件。 - ge(String fieldName, Object value): 添加大于等于条件。 - lt(String fieldName, Object value): 添加小于条件。 - le(String fieldName, Object value): 添加小于等于条件。 - between(String fieldName, Object start, Object end): 添加范围条件。 - isNull(String fieldName): 添加空值检查条件。 - isNotNull(String fieldName): 添加非空值检查条件。 - in(String fieldName, List values): 添加 IN 条件。 - like(String fieldName, String value): 添加 LIKE 条件。 JSON and Array Operations: - jsonContains(String fieldName, Object value): 添加 JSON 包含条件。 - jsonContainsAll(String fieldName, List values): 添加 JSON 包含所有值的条件。 - jsonContainsAny(String fieldName, List values): 添加 JSON 包含任意值的条件。 - arrayContains(String fieldName, Object value): 添加数组包含条件。 - arrayContainsAll(String fieldName, List values): 添加数组包含所有值的条件。 - arrayContainsAny(String fieldName, List values): 添加数组包含任意值的条件。 - arrayLength(String fieldName, int length): 添加数组长度条件。 Logical Operations: - and(ConditionBuilder other): 添加 AND 条件。 - or(ConditionBuilder other): 添加 OR 条件。 - not(): 添加 NOT 条件。 Vector Search Settings: - annsField(String annsField): 设置要搜索的向量字段。 - vector(List vector): 添加要搜索的向量。 - vector(String annsField, List vector): 设置向量字段并添加要搜索的向量。 - topK(Integer topK): 设置返回的 top-k 结果。 - limit(Long limit): 设置查询结果的数量限制。 Executing Queries: - query(): 构建并执行搜索请求,返回封装的 MilvusResp 对象,其中包含查询结果。 - query(FieldFunction ... outputFields): 设置输出字段并执行查询。 - query(String ... outputFields): 设置输出字段并执行查询。 - getById(Serializable ... ids): 通过 ID 获取数据。 Helper Methods: - buildSearch(): 构建完整的搜索请求对象。 - buildQuery(): 构建查询请求对象. ``` -------------------------------- ### MilvusPlus Mapper Classes API Reference Source: https://github.com/dromara/milvusplus/blob/main/README.md API documentation for `MilvusMapper` and `BaseMilvusMapper` classes, providing methods for Milvus client interaction, query/delete/update/insert wrapper creation, and core data manipulation operations. ```APIDOC MilvusMapper - getClient(): Returns a MilvusClientV2 instance. BaseMilvusMapper - queryWrapper(): Creates a LambdaQueryWrapper instance. - deleteWrapper(): Creates a LambdaDeleteWrapper instance. - updateWrapper(): Creates a LambdaUpdateWrapper instance. - insertWrapper(): Creates a LambdaInsertWrapper instance. Data Operations: - getById(Serializable ... ids) - Function: Query data based on the provided list of IDs. - Parameters: ids - A list of serializable IDs. - Return: MilvusResp>> - The response containing the query results. - removeById(Serializable ... ids) - Function: Delete data based on the provided list of IDs. - Parameters: ids - A list of serializable IDs. - Return: MilvusResp - The response of the deletion operation. - updateById(T ... entity) - Function: Update data based on the provided entities. - Parameters: entity - A list of entity objects. - Return: MilvusResp - The response of the update operation. - insert(T ... entity) - Function: Insert the provided entities into the database. - Parameters: entity - A list of entity objects. - Return: MilvusResp - The response of the insertion operation. Builder Methods: - lambda(Wrapper wrapper): Initializes and returns a builder instance. ``` -------------------------------- ### MilvusPlus ICMService API Reference Source: https://github.com/dromara/milvusplus/blob/main/README.md API methods for managing collections, fields, partitions, and indexes in MilvusPlus, covering creation, deletion, description, and data loading. ```APIDOC createCollection(MilvusEntity milvusEntity) - Creates a new collection based on the provided MilvusEntity configuration. addField(String collectionName, AddFieldReq ... addFieldReq) - Adds one or more fields to an existing collection. getField(String collectionName, String fieldName) - Retrieves information about a specific field within a collection. describeCollection(String collectionName) - Retrieves detailed information about a specified collection. dropCollection(String collectionName) - Deletes an existing collection. hasCollection(String collectionName) - Checks if a collection with the specified name exists. getCollectionStats(String collectionName) - Retrieves statistics for a specified collection. renameCollection(String oldCollectionName, String newCollectionName) - Renames an existing collection. createIndex(String collectionName, List indexParams) - Creates an index for a collection based on the provided parameters. describeIndex(String collectionName, String fieldName) - Retrieves information about the index on a specific field within a collection. dropIndex(String collectionName, String fieldName) - Deletes the index on a specific field within a collection. getLoadState(String collectionName, String partitionName) - Retrieves the loading status of a collection or a specific partition. loadCollection(String collectionName) - Loads all data of a collection into memory. releaseCollection(String collectionName) - Releases all data of a collection from memory. createPartition(String collectionName, String partitionName) - Creates a new partition within a specified collection. dropPartition(String collectionName, String partitionName) - Deletes an existing partition from a collection. hasPartition(String collectionName, String partitionName) - Checks if a partition with the specified name exists within a collection. listPartitions(String collectionName) - Lists all partitions within a specified collection. loadPartitions(String collectionName, List partitionNames) - Loads specified partitions of a collection into memory. releasePartitions(String collectionName, List partitionNames) - Releases specified partitions of a collection from memory. ``` -------------------------------- ### MilvusService Common API Methods Source: https://github.com/dromara/milvusplus/blob/main/README.cn.md Provides utility methods for MilvusService, such as obtaining the Milvus client instance. ```APIDOC getClient() - Retrieves the MilvusClientV2 instance. - Returns: An instance of MilvusClientV2. ``` -------------------------------- ### MilvusPlus MilvusService Functionality Overview Source: https://github.com/dromara/milvusplus/blob/main/README.md Provides a comprehensive overview of the `MilvusService`, detailing its role in full management of the Milvus database and the key interfaces it implements for various management functionalities. ```APIDOC MilvusService Functionality: MilvusService is a comprehensive service that provides full management of the Milvus database. It implements multiple interfaces: - IAMService (Identity and Access Management Service) - ICMService (Collection Management Service) - IVecMService (Vector Management Service) ``` -------------------------------- ### MilvusPlus LambdaInsertWrapper API for Data Insertion Source: https://github.com/dromara/milvusplus/blob/main/README.cn.md API documentation for `LambdaInsertWrapper`, a builder class for constructing and executing data insertion operations in Milvus. It includes methods for specifying partitions and assigning field values for the data to be inserted. ```APIDOC LambdaInsertWrapper Class Documentation Methods: - partition(String partitionName): 添加分区。 - put(String fieldName, Object value): 添加字段值。 ``` -------------------------------- ### MilvusMapper and BaseMilvusMapper API Reference Source: https://github.com/dromara/milvusplus/blob/main/README.cn.md API documentation for MilvusMapper and BaseMilvusMapper in MilvusPlus, providing generic interfaces for Milvus database operations including querying, deleting, updating, and inserting. It details methods for obtaining the Milvus client and creating various wrapper instances for fluent API usage. ```APIDOC MilvusMapper: - Description: A generic abstract class inheriting from BaseMilvusMapper, providing basic methods for interacting with the Milvus client. - Methods: - getClient(): Returns a MilvusClientV2 instance. BaseMilvusMapper: - Description: An abstract class defining fundamental operations for interacting with the Milvus database. - Methods: - queryWrapper(): Creates a LambdaQueryWrapper instance for building search queries. - deleteWrapper(): Creates a LambdaDeleteWrapper instance for building delete operations. - updateWrapper(): Creates a LambdaUpdateWrapper instance for building update operations. - insertWrapper(): Creates a LambdaInsertWrapper instance for building insert operations. ``` -------------------------------- ### MilvusPlus IAMService API Reference Source: https://github.com/dromara/milvusplus/blob/main/README.md API methods for managing users, roles, and permissions within MilvusPlus, including creation, deletion, querying, and privilege management. ```APIDOC createRole(String roleName) - Creates a new role with the specified name. createUser(String userName, String password) - Creates a new user with the given username and password. describeRole(String roleName) - Retrieves detailed permissions and information for a specified role. describeUser(String userName) - Retrieves detailed information for a specified user. dropRole(String roleName) - Deletes an existing role. dropUser(String userName) - Deletes an existing user. grantPrivilege(String roleName, String objectType, String privilege, String objectName) - Grants a specific privilege on an object to a role. grantRole(String roleName, String userName) - Assigns an existing role to a user. listRoles() - Lists all available roles. listUsers() - Lists all registered users. revokePrivilege(String roleName, String objectType, String privilege, String objectName, String databaseName) - Revokes a specific privilege on an object from a role. revokeRole(String roleName, String userName) - Removes a role from a user. updatePassword(String userName, String password, String newPassword) - Updates the password for a specified user. ``` -------------------------------- ### MilvusPlus LambdaDeleteWrapper API for Data Deletion Source: https://github.com/dromara/milvusplus/blob/main/README.cn.md API documentation for `LambdaDeleteWrapper`, a builder class for constructing and executing data deletion operations in Milvus. It includes methods for specifying partitions, adding query conditions, and triggering the deletion process. ```APIDOC LambdaDeleteWrapper Class Documentation Methods: - partition(String partitionName): 添加分区。 - eq(String fieldName, Object value): 添加等于条件。 - ne(String fieldName, Object value): 添加不等于条件。 - id(Object id): 添加 ID 到删除列表。 Executing Deletion: - remove(): 构建并执行删除请求。 - removeById(Serializable ... ids): 通过 ID 删除。 ``` -------------------------------- ### MilvusService IAMService API Reference Source: https://github.com/dromara/milvusplus/blob/main/README.cn.md Provides methods for identity and access management within Milvus, including user and role creation, deletion, querying, and privilege management. ```APIDOC createRole(String roleName) - Creates a new role. - Parameters: - roleName: The name of the role to create. createUser(String userName, String password) - Creates a new user. - Parameters: - userName: The username for the new user. - password: The password for the new user. describeRole(String roleName) - Queries the permissions of a specific role. - Parameters: - roleName: The name of the role to describe. describeUser(String userName) - Queries information about a specific user. - Parameters: - userName: The name of the user to describe. dropRole(String roleName) - Deletes an existing role. - Parameters: - roleName: The name of the role to delete. dropUser(String userName) - Deletes an existing user. - Parameters: - userName: The name of the user to delete. grantPrivilege(String roleName, String objectType, String privilege, String objectName) - Grants a privilege to a role. - Parameters: - roleName: The name of the role. - objectType: The type of object (e.g., 'Collection', 'Database'). - privilege: The privilege to grant (e.g., 'Read', 'Write'). - objectName: The name of the object. grantRole(String roleName, String userName) - Grants a role to a user. - Parameters: - roleName: The name of the role to grant. - userName: The name of the user to whom the role is granted. listRoles() - Lists all existing roles. listUsers() - Lists all existing users. revokePrivilege(String roleName, String objectType, String privilege, String objectName, String databaseName) - Revokes a privilege from a role. - Parameters: - roleName: The name of the role. - objectType: The type of object. - privilege: The privilege to revoke. - objectName: The name of the object. - databaseName: The name of the database. revokeRole(String roleName, String userName) - Revokes a role from a user. - Parameters: - roleName: The name of the role to revoke. - userName: The name of the user from whom the role is revoked. updatePassword(String userName, String password, String newPassword) - Updates a user's password. - Parameters: - userName: The name of the user. - password: The current password. - newPassword: The new password. ``` -------------------------------- ### MilvusPlus Application Configuration Source: https://github.com/dromara/milvusplus/blob/main/README.cn.md YAML configuration for connecting MilvusPlus to a Milvus service. It specifies the Milvus URI, authentication token, module enablement, logging options, optional database name, credentials, and packages to scan for entity classes. ```YAML milvus: uri: https://in03-a5357975ab80da7.api.gcp-us-west1.zillizcloud.com token: x'x'x'x enable: true open-log: true (默认 false 不打印) db-name: (可选) username: (可选) password: (可选) packages: - com.example.entity ``` -------------------------------- ### MilvusPlus LambdaUpdateWrapper API for Data Update Source: https://github.com/dromara/milvusplus/blob/main/README.cn.md API documentation for `LambdaUpdateWrapper`, a builder class for constructing and executing data update operations in Milvus. It provides methods for specifying partitions, setting update conditions, and performing the update. ```APIDOC LambdaUpdateWrapper Class Documentation Methods: - partition(String partitionName): 添加分区。 - 设置更新条件: 与 LambdaDeleteWrapper 相同 (e.g., eq, ne, etc.). Executing Update: - update(T t): 构建并执行更新请求。 - updateById(T ... t): 通过 ID 更新。 ``` -------------------------------- ### MilvusPlus Maven Dependencies Source: https://github.com/dromara/milvusplus/blob/main/README.cn.md Maven dependencies for integrating MilvusPlus into Java projects. This includes the core library, Spring Boot starter for Spring applications, and Solon plugin for Solon framework integration. ```XML org.dromara.milvus-plus milvus-plus-core 2.2.4 ``` ```XML org.dromara.milvus-plus milvus-plus-boot-starter 2.2.4 ``` ```XML org.dromara.milvus-plus milvus-plus-solon-plugin 2.2.4 ``` -------------------------------- ### MilvusPlus LambdaInsertWrapper API Reference Source: https://github.com/dromara/milvusplus/blob/main/README.md A builder class for constructing and executing insertion operations in Milvus, allowing specification of partitions and field values for new data entries. ```APIDOC LambdaInsertWrapper API: Configuration: partition(String partitionName) - Adds a partition to the insertion scope. - Parameters: - partitionName: The name of the partition. Field Value Setting: put(String fieldName, Object value) - Adds a field and its value to be inserted. - Parameters: - fieldName: The name of the field to insert. - value: The value for the field. Executing Insertion: insert() - Builds and executes the insertion request. insert(T ... t) - Inserts multiple data entries. - Parameters: - t: Variable arguments for data objects to insert. ``` -------------------------------- ### MilvusPlus Application Configuration Schema Source: https://github.com/dromara/milvusplus/blob/main/README.md Defines the structure and parameters for configuring MilvusPlus in an application, including connection details, authentication, module enablement, and package scanning for entity classes. This configuration block is typically placed in a YAML or properties file. ```YAML milvus: uri: https://in03-a5357975ab80da7.api.gcp-us-west1.zillizcloud.com token: x'x'x'x enable: true packages: - com.example.entity ``` ```APIDOC milvus: uri: The URI of the Milvus service, through which the application communicates with the Milvus service. token: A token for verification and authorization, ensuring the security of access to the Milvus service. enable: A boolean value indicating whether the Milvus module should be enabled. packages: These packages contain Java classes corresponding to custom annotations, which you can consider as the package where your custom entity classes are located. ``` -------------------------------- ### MilvusPlus LambdaDeleteWrapper API Reference Source: https://github.com/dromara/milvusplus/blob/main/README.md A builder class for constructing and executing deletion operations in Milvus, allowing specification of partitions, conditions, and direct ID-based deletion. ```APIDOC LambdaDeleteWrapper API: Configuration: partition(String partitionName) - Adds a partition to the deletion scope. - Parameters: - partitionName: The name of the partition. Conditions: eq(String fieldName, Object value) - Adds an equal condition for deletion. - Parameters: - fieldName: The name of the field. - value: The value to match. ne(String fieldName, Object value) - Adds a not equal condition for deletion. - Parameters: - fieldName: The name of the field. - value: The value to not match. id(Object id) - Adds an ID to the deletion list. - Parameters: - id: The ID of the record to delete. Executing Deletion: remove() - Builds and executes the deletion request. removeById(Serializable ... ids) - Deletes data by ID. - Parameters: - ids: Variable arguments for IDs to delete. ``` -------------------------------- ### MilvusPlus LambdaQueryWrapper API Reference Source: https://github.com/dromara/milvusplus/blob/main/README.md Provides a fluent API for constructing complex Milvus search queries, supporting various conditions, logical operations, JSON/array operations, and vector searches. Users can chain methods to build flexible search requests. ```APIDOC LambdaQueryWrapper API: Query Condition Construction: eq(String fieldName, Object value) - Adds an equal condition. - Parameters: - fieldName: The name of the field. - value: The value to compare against. ne(String fieldName, Object value) - Adds a not equal condition. - Parameters: - fieldName: The name of the field. - value: The value to compare against. gt(String fieldName, Object value) - Adds a greater than condition. - Parameters: - fieldName: The name of the field. - value: The value to compare against. ge(String fieldName, Object value) - Adds a greater than or equal condition. - Parameters: - fieldName: The name of the field. - value: The value to compare against. lt(String fieldName, Object value) - Adds a less than condition. - Parameters: - fieldName: The name of the field. - value: The value to compare against. le(String fieldName, Object value) - Adds a less than or equal condition. - Parameters: - fieldName: The name of the field. - value: The value to compare against. between(String fieldName, Object start, Object end) - Adds a range condition. - Parameters: - fieldName: The name of the field. - start: The start value of the range (inclusive). - end: The end value of the range (inclusive). isNull(String fieldName) - Adds a null check condition. - Parameters: - fieldName: The name of the field. isNotNull(String fieldName) - Adds a not null check condition. - Parameters: - fieldName: The name of the field. in(String fieldName, List values) - Adds an IN condition. - Parameters: - fieldName: The name of the field. - values: A list of values to check for containment. like(String fieldName, String value) - Adds a LIKE condition. - Parameters: - fieldName: The name of the field. - value: The pattern to match. JSON and Array Operations: jsonContains(String fieldName, Object value) - Adds a JSON contains condition. - Parameters: - fieldName: The name of the JSON field. - value: The value to check for containment within the JSON field. jsonContainsAll(String fieldName, List values) - Adds a JSON contains all values condition. - Parameters: - fieldName: The name of the JSON field. - values: A list of values, all of which must be contained within the JSON field. jsonContainsAny(String fieldName, List values) - Adds a JSON contains any value condition. - Parameters: - fieldName: The name of the JSON field. - values: A list of values, at least one of which must be contained within the JSON field. arrayContains(String fieldName, Object value) - Adds an array contains condition. - Parameters: - fieldName: The name of the array field. - value: The value to check for containment within the array field. arrayContainsAll(String fieldName, List values) - Adds an array contains all values condition. - Parameters: - fieldName: The name of the array field. - values: A list of values, all of which must be contained within the array field. arrayContainsAny(String fieldName, List values) - Adds an array contains any value condition. - Parameters: - fieldName: The name of the array field. - values: A list of values, at least one of which must be contained within the array field. arrayLength(String fieldName, int length) - Adds an array length condition. - Parameters: - fieldName: The name of the array field. - length: The expected length of the array. Logical Operations: and(ConditionBuilder other) - Adds an AND condition. - Parameters: - other: Another ConditionBuilder instance to combine with an AND operator. or(ConditionBuilder other) - Adds an OR condition. - Parameters: - other: Another ConditionBuilder instance to combine with an OR operator. not() - Adds a NOT condition. Vector Search Settings: annsField(String annsField) - Sets the vector field to be searched. - Parameters: - annsField: The name of the vector field. vector(List vector) - Adds the vector to be searched. - Parameters: - vector: The vector data. vector(String annsField, List vector) - Sets the vector field and adds the vector to be searched. - Parameters: - annsField: The name of the vector field. - vector: The vector data. topK(Integer topK) - Sets the top-k results to be returned. - Parameters: - topK: The number of top results to retrieve. limit(Long limit) - Sets the limit on the number of query results. - Parameters: - limit: The maximum number of results to return. Executing Queries: query() - Builds and executes the search request, returning a wrapped MilvusResp object containing the query results. - Returns: A MilvusResp object with query results. query(FieldFunction ... outputFields) - Sets the output fields and executes the query. - Parameters: - outputFields: Variable arguments for fields to include in the output. - Returns: A MilvusResp object with query results. query(String ... outputFields) - Sets the output fields and executes the query. - Parameters: - outputFields: Variable arguments for field names (as strings) to include in the output. - Returns: A MilvusResp object with query results. getById(Serializable ... ids) - Gets data by ID. - Parameters: - ids: Variable arguments for IDs to retrieve. Helper Methods: buildSearch() - Builds a complete search request object. - Returns: A search request object. buildQuery() - Builds a query request object. - Returns: A query request object. ``` -------------------------------- ### MilvusPlus Client Access API Source: https://github.com/dromara/milvusplus/blob/main/README.md Provides a public method to obtain an instance of the MilvusClientV2 for interacting with the MilvusPlus service. ```APIDOC getClient() - Returns an instance of MilvusClientV2, allowing interaction with the MilvusPlus service. ``` -------------------------------- ### Configure MilvusPlus Entity for Text Analysis and Matching (Java) Source: https://github.com/dromara/milvusplus/blob/main/Tantivy文本匹配.md This Java code snippet demonstrates how to enable text analysis and matching for a field in a Milvus entity. By setting `enableAnalyzer` and `enableMatch` to `true` on the `@MilvusField` annotation, Milvus will tokenize the text and create an inverted index, facilitating efficient text-based searches. ```java import org.dromara.milvus.plus.annotation.*; public class TextEntity { @MilvusField( name = "text", dataType = DataType.VarChar, enableAnalyzer = true, enableMatch = true ) private String text; } ```