Skip to content

Conversation

@bevzzz
Copy link
Collaborator

@bevzzz bevzzz commented Nov 19, 2025

This PR is decouples "read-objects" (returned from queries) from "write-objects" (used to insert new objects in a collection. This allows us to get rid of the 2 generic parameters (R -> reference type, and M -> metadata type), which also depended on the context in which the object was being used.

Since the values for generic types were strictly bound to the context, they did not offer any additional benefit to the end user and only added unnecessary burden (more typing + more thinking about generics).

The new approach is to have dedicated WriteWeaviateObject, which exposes all fields a user can set when inserting new objects, and a ReadWeaviateObject, which holds query metadata and retrieved reference objects (if any).

Previously WeaviateObject class could be used in Reference.objects() to insert newly created / retrieved objects as references. We cover that use case by making WeaviateObject an interface that both read- and write- variants implement.

This works:

var inserted = movies.data.insert(Map.of("title", "Death At A Funeral"));
var retrieved = movies.query.fetchObjectById(inserted.uuid()).get(); // Optional<>

Reference.objects(inserted, retrieved);

The syntax for providing a custom UUID and vector is simplified too: instead of putting these behind a metadata call, the builder for WriteWeaviateObject has methods to set them directly:

WriteWeaviateObject.of(obj -> obj|
  .uuid("uuid-1")
  .properties(...)
  .vectors(Vectors.of(...)));

Adding multiple vectors is simpler too, as .vectors() calls can now be chained.
When iterating over a list of vectors from another source, it is not necessary to collect them in a Vectors[] first, as it was before.

var object = new WriteWeaviateObject.Builder<Map<String, Object>>();
for (float[] v : vectors) {
   object.vectors(Vectors.of(makeVectorName(), v));
}
for (float[][] v : multiVectors) {
   object.vectors(Vectors.of(makeVectorName(), v));
}
object.build(); // has all vector embeddings

Call object.vectors().size() to see how many vectors were inserted / retrieved.

N.B.: ReadWeaviateObject does not have the tenant field, because it's not part of the server's response.

Copy link

@orca-security-eu orca-security-eu bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca

@bevzzz bevzzz merged commit ab9967b into v6 Nov 21, 2025
2 checks passed
@bevzzz bevzzz deleted the v6-weaviate-object branch November 21, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants