2dcf826dcf
## Issue Closes #6087 ## Change `buildQueryExpression` concatenated caller-supplied ids into `id == '<id>' || ...` without quoting or escaping them. It now uses the `in` form with the module's existing value formatter: ```java return format("%s in %s", idFieldName, formatValues(rowIds)); ``` That is the same shape `MilvusEmbeddingStore.removeAll(Collection<String> ids)` already uses for caller-supplied ids, down to the static import of `formatValues` from the metadata filter mapper, so the id query path now formats values the way the delete path and the metadata filters do instead of hand-rolling it. It also collapses the expression from one `==` term per id to a single `in`. Both modules carried the identical line, so both are fixed. One dependent change: `MilvusV2MetadataFilterMapper.formatValue` escaped double quotes but not backslashes, so it never received the fix `MilvusMetadataFilterMapper` got in #5577. Since the id expression is now routed through that formatter, v2 would still mishandle an id containing a backslash without it. The v2 formatter now matches v1. `rowIds` is never empty at this point: both callers guard on the search result being non-empty before querying for vectors, so the expression shape is unchanged for every reachable input. ### Tests - `langchain4j-milvus/CollectionRequestBuilderTest` (new): a normal id, an id with an apostrophe, an id with a double quote and an id with a backslash, plus a single-id expression - `langchain4j-milvus-v2/CollectionRequestBuilderTest`: the same matrix, added to the existing class - `langchain4j-milvus-v2/MilvusV2MetadataFilterMapperTest` (new): mirrors the backslash tests #5577 added to the v1 mapper, which had no v2 counterpart Six fail on unmodified `main` (2 in v1, 1 in the v2 builder, 3 in the v2 mapper). The no-special-characters case passes either way, it pins formatting that must not change. ``` mvn -pl langchain4j-milvus test Tests run: 12, Failures: 0, Errors: 0, Skipped: 0 mvn -pl langchain4j-milvus-v2 test Tests run: 27, Failures: 0, Errors: 0, Skipped: 0 mvn -pl langchain4j-milvus verify -DskipTests mvn -pl langchain4j-milvus-v2 verify -DskipTests revapi: API checks completed without failures (both) langchain4j-core: Tests run: 1247, Failures: 0, Errors: 0, Skipped: 4 langchain4j: Tests run: 1331, Failures: 0, Errors: 0, Skipped: 0 ``` Milvus integration tests need a running Milvus and were not run. ## General checklist - [ ] There are no breaking changes (API, behaviour) - [X] I have added unit and/or integration tests for my change - [X] The tests cover both positive and negative cases - [X] I have manually run all the unit and integration tests in the module I have added/changed, and they are all green - [X] I have manually run all the unit and integration tests in the [core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core) and [main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j) modules, and they are all green - [ ] I have added/updated the [documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs) - [ ] I have added an example in the [examples repo](https://github.com/langchain4j/langchain4j-examples) (only for "big" features) - [ ] I have added/updated [Spring Boot starter(s)](https://github.com/langchain4j/langchain4j-spring) (if applicable) --------- Co-authored-by: Dmytro Liubarskyi <ljubarskij@gmail.com>