From 10ebcbf53f0ac9955270f1493ffb9c144cea1b52 Mon Sep 17 00:00:00 2001 From: Pankaj Singh Date: Tue, 10 Mar 2026 10:09:04 +0530 Subject: [PATCH 1/2] feat: add update filter --- README.md | 31 ++++++++++++++-- src/main/java/io/endee/client/Index.java | 37 +++++++++++++++++++ .../client/types/UpdateFilterParams.java | 22 +++++++++++ 3 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 src/main/java/io/endee/client/types/UpdateFilterParams.java diff --git a/README.md b/README.md index 2074948..dfb0a92 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,30 @@ You can also query with: - **Sparse only**: Provide only `sparseIndices` and `sparseValues` - **Hybrid**: Provide all three for combined results +## Updating Filters + +Use `index.updateFilters()` to update the filter fields of existing vectors without re-upserting them. + +```java +import io.endee.client.types.UpdateFilterParams; +import java.util.List; +import java.util.Map; + +index.updateFilters(List.of( + new UpdateFilterParams("vec1", Map.of("category", "ml", "score", 95)), + new UpdateFilterParams("vec2", Map.of("category", "science", "score", 80)) +)); +``` + +**`UpdateFilterParams` Fields:** + +| Field | Required | Description | +| -------- | -------- | -------------------------------------------------- | +| `id` | Yes | ID of the vector to update | +| `filter` | Yes | New filter object to replace the existing filter | + +> **Note:** The entire filter object is replaced, not merged. + ## Deletion Methods ### Delete by ID @@ -522,9 +546,10 @@ public class EndeeExample { | Method | Parameters | Return Type | Description | | ----------------------------- | ---------- | ------------------- | -------------------------- | -| `upsert(List)` | `vectors` | `String` | Insert or update vectors | -| `query(QueryOptions)` | `options` | `List` | Search for similar vectors | -| `deleteVector(String id)` | `id` | `String` | Delete a vector by ID | +| `upsert(List)` | `vectors` | `String` | Insert or update vectors | +| `query(QueryOptions)` | `options` | `List` | Search for similar vectors | +| `updateFilters(List)` | `updates` | `String` | Update filter fields on existing vectors | +| `deleteVector(String id)` | `id` | `String` | Delete a vector by ID | | `deleteWithFilter(List)` | `filter` | `String` | Delete vectors by filter | | `getVector(String id)` | `id` | `VectorInfo` | Get a vector by ID | | `describe()` | - | `IndexDescription` | Get index metadata | diff --git a/src/main/java/io/endee/client/Index.java b/src/main/java/io/endee/client/Index.java index 269e36b..118fbbe 100644 --- a/src/main/java/io/endee/client/Index.java +++ b/src/main/java/io/endee/client/Index.java @@ -341,6 +341,43 @@ public List query(QueryOptions options) { } } + /** + * Updates the filter fields of existing vectors without re-upserting them. + * + * @param updates list of filter updates, each containing an id and the new filter object + * @return success message + */ + public String updateFilters(List updates) { + List ids = updates.stream().map(UpdateFilterParams::getId).collect(Collectors.toList()); + ValidationUtils.validateVectorIds(ids); + + List> payload = new ArrayList<>(); + for (UpdateFilterParams update : updates) { + Map entry = new HashMap<>(); + entry.put("id", update.getId()); + entry.put("filter", update.getFilter() != null ? update.getFilter() : Map.of()); + payload.add(entry); + } + + try { + String jsonBody = JsonUtils.toJson(Map.of("updates", payload)); + HttpRequest request = buildPostJsonRequest("/index/" + name + "/filters/update", jsonBody); + HttpResponse response = + httpClient.send(request, HttpResponse.BodyHandlers.ofString()); + + if (response.statusCode() != 200) { + EndeeApiException.raiseException(response.statusCode(), response.body()); + } + + return response.body(); + } catch (IOException | InterruptedException e) { + if (e instanceof InterruptedException) { + Thread.currentThread().interrupt(); + } + throw new EndeeException("Failed to update filters", e); + } + } + /** * Deletes a vector by ID. * diff --git a/src/main/java/io/endee/client/types/UpdateFilterParams.java b/src/main/java/io/endee/client/types/UpdateFilterParams.java new file mode 100644 index 0000000..5a83970 --- /dev/null +++ b/src/main/java/io/endee/client/types/UpdateFilterParams.java @@ -0,0 +1,22 @@ +package io.endee.client.types; + +import java.util.Map; + +/** Parameters for updating the filter fields of an existing vector. */ +public class UpdateFilterParams { + private final String id; + private final Map filter; + + public UpdateFilterParams(String id, Map filter) { + this.id = id; + this.filter = filter; + } + + public String getId() { + return id; + } + + public Map getFilter() { + return filter; + } +} From f349c420ca74633ba0b5066f00ae47827ec29d77 Mon Sep 17 00:00:00 2001 From: Pankaj Singh Date: Tue, 10 Mar 2026 10:12:57 +0530 Subject: [PATCH 2/2] chore: bump version to 1.0.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 002bcff..305ea7a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.endee endee-java-client - 0.1.6-SNAPSHOT + 1.0.0-SNAPSHOT jar Endee Java Client