Skip to main content
Go to documentation:
⌘U
Weaviate Database

Develop AI applications using Weaviate's APIs and tools

Deploy

Deploy, configure, and maintain Weaviate Database

Query Agent

Run agentic search over your Weaviate Cloud collections

Weaviate Cloud

Manage and scale Weaviate in the cloud

Engram

Persistent memory for LLM agents and applications

Additional resources

Integrations
Weaviate Academy

Need help?

Weaviate LogoAsk AI Assistant⌘K
Support
Community Forum
Contributor guide

Read all objects

Weaviate provides the necessary APIs to iterate through all your data. This is useful when you want to manually copy/migrate your data (and vector embeddings) from one place to another.

This is done with the help of the after operator, also called the cursor API.

Iterator

Some clients, such as the Python client, encapsulate this functionality as an Iterator.

Read object properties and ids​

The following code iterates through all objects, providing the properties and id for each object.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
collection = client.collections.use("WineReview")

for item in collection.iterator():
print(item.uuid, item.properties)
const myCollection = client.collections.use("WineReview");

for await (let item of myCollection.iterator()) {
console.log(item.uuid, item.properties);
}
sourceClient, err := weaviate.NewClient(weaviate.Config{
Scheme: "https",
Host: "WEAVIATE_INSTANCE_URL", // Replace WEAVIATE_INSTANCE_URL with your instance URL
AuthConfig: auth.ApiKey{
Value: "YOUR-WEAVIATE-API-KEY", // If auth enabled. Replace with your Weaviate instance API key.
},
})
if err != nil {
// handle error
panic(err)
}

batchSize := 20
className := "WineReview"
classProperties := []string{"title"}

getBatchWithCursor := func(client weaviate.Client,
className string, classProperties []string, batchSize int, cursor string) (*models.GraphQLResponse, error) {
fields := []graphql.Field{}
for _, prop := range classProperties {
fields = append(fields, graphql.Field{Name: prop})
}
fields = append(fields, graphql.Field{Name: "_additional { id vector }"})

get := client.GraphQL().Get().
WithClassName(className).
// Optionally retrieve the vector embedding by adding `vector` to the _additional fields
WithFields(fields...).
WithLimit(batchSize)

if cursor != "" {
return get.WithAfter(cursor).Do(context.Background())
}
return get.Do(context.Background())
}
collection := client.Collections.Use("WineReview")

iter := collection.Objects(ctx)
for {
obj, err := iter.Next()
if err == iterator.Done {
break
}
if err != nil {
// handle error
panic(err)
}
fmt.Println(obj.UUID, obj.Properties)
}
CollectionHandle<Map<String, Object>> collection =
client.collections.use("WineReview");

for (WeaviateObject<Map<String, Object>> item : collection.paginate()) {
System.out.printf("%s %s\n", item.uuid(), item.properties());
}
var collection = client.Collections.Use("WineReview");

await foreach (var item in collection.Iterator())
{
Console.WriteLine($"{item.UUID} {JsonSerializer.Serialize(item.Properties)}");
}
Returned properties

By default, all properties and object UUIDs are returned. Blob and reference properties are excluded unless specified otherwise. This does not apply to the Go client library.

Read all objects including vectors​

Read through all data including the vectors. (Also applicable where named vectors are used.)

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
collection = client.collections.use("WineReview")

for item in collection.iterator(
include_vector=True # If using named vectors, you can specify ones to include e.g. ['title', 'body'], or True to include all
):
print(item.properties)
print(item.vector)
const myCollection = client.collections.use("WineReview");

for await (let item of myCollection.iterator({
includeVector: true
})) {
console.log(item.uuid, item.properties);
console.log(item.vectors);
}
collection := client.Collections.Use("WineReview")

// The object iterator returns no vectors, so page with After and request them.
var after uuid.UUID
for {
res, err := collection.Query.OverAll(ctx, query.OverAll{
Limit: 100,
After: after,
ReturnVectors: []string{"default"},
})
if err != nil {
// handle error
panic(err)
}
if len(res.Objects) == 0 {
break
}
for _, obj := range res.Objects {
fmt.Println(obj.Properties)
fmt.Println(obj.Vectors["default"].Single)
}
after = res.Objects[len(res.Objects)-1].UUID
}
CollectionHandle<Map<String, Object>> collection =
client.collections.use("WineReview");

for (WeaviateObject<Map<String, Object>> item : collection.paginate(
i -> i.returnMetadata() // If using named vectors, you can specify ones to include
)) {
System.out.println(item.properties());
System.out.println(item.vectors());
}
var collection = client.Collections.Use("WineReview");

await foreach (
var item in collection.Iterator(
includeVectors: true // If using named vectors, you can specify ones to include
)
)
{
Console.WriteLine(JsonSerializer.Serialize(item.Properties));
Console.WriteLine(JsonSerializer.Serialize(item.Vectors));
}

Read all objects - Multi-tenant collections​

Iterate through all tenants and read data for each.

Multi-tenancy

For classes where multi-tenancy is enabled, you need to specify the tenant name when reading or creating objects. See Manage data: multi-tenancy operations for details.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
multi_collection = client.collections.use("WineReviewMT")

# Get a list of tenants
tenants = multi_collection.tenants.get()

# Iterate through tenants
for tenant_name in tenants.keys():
# Iterate through objects within each tenant
for item in multi_collection.with_tenant(tenant_name).iterator():
print(f"{tenant_name}: {item.properties}")
const multiCollection = client.collections.use("WineReviewMT");

const tenants = await multiCollection.tenants.get()

for (let tenantName in tenants) {
for await (let item of multiCollection.withTenant(tenantName).iterator()) {
console.log(`${tenantName}:`, item.properties);
}
}
multiCollection := client.Collections.Use("WineReviewMT")

// Get a list of tenants
tenants, err := multiCollection.Tenants.Get(ctx)
if err != nil {
// handle error
panic(err)
}

// Iterate through tenants
for _, tn := range tenants {
// Iterate through objects within each tenant
iter := multiCollection.WithOptions(collections.WithTenant(tn.Name)).Objects(ctx)
for {
obj, err := iter.Next()
if err == iterator.Done {
break
}
if err != nil {
// handle error
panic(err)
}
fmt.Printf("%s: %v\n", tn.Name, obj.Properties)
}
}
CollectionHandle<Map<String, Object>> multiCollection =
client.collections.use("WineReviewMT");

// Get a list of tenants
var tenants = multiCollection.tenants.get();

// Iterate through tenants
for (Tenant tenant : tenants) {
// Iterate through objects within each tenant
for (WeaviateObject<Map<String, Object>> item : multiCollection
.withTenant(tenant.name())
.paginate()) {
System.out.printf("%s: %s\n", tenant.name(), item.properties());
}
}
var multiCollection = client.Collections.Use("WineReviewMT");

// Get a list of tenants
var tenants = await multiCollection.Tenants.List();

// Iterate through tenants
foreach (var tenant in tenants)
{
// Iterate through objects within each tenant
var tenantCollection = multiCollection.WithTenant(tenant.Name);
await foreach (var item in tenantCollection.Iterator())
{
Console.WriteLine($"{tenant.Name}: {JsonSerializer.Serialize(item.Properties)}");
}
}

Questions and feedback​