Skip to main content
Weaviate Docs (migrated from docs.weaviate.io) Docs

Search documentation

Type to search this documentation.

On this pageOverview

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.

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

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

for await (let item of myCollection.iterator()) {
  console.log(item.uuid, item.properties);
}
Go
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 := 20className := "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())}
Java
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());}
C#
var collection = client.Collections.Use("WineReview");await foreach (var item in collection.Iterator()){    Console.WriteLine($"{item.UUID} {JsonSerializer.Serialize(item.Properties)}");}

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

Python
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)
JavaScript/TypeScript
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);
}
Java
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());}
C#
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));}

Iterate through all tenants and read data for each.

Python
multi_collection = client.collections.use("WineReviewMT")# Get a list of tenantstenants = multi_collection.tenants.get()# Iterate through tenantsfor 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}")
JavaScript/TypeScript
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);
  }
}
Java
CollectionHandle<Map<String, Object>> multiCollection =    client.collections.use("WineReviewMT");// Get a list of tenantsvar tenants = multiCollection.tenants.get();// Iterate through tenantsfor (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());  }}
C#
var multiCollection = client.Collections.Use("WineReviewMT");// Get a list of tenantsvar tenants = await multiCollection.Tenants.List();// Iterate through tenantsforeach (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)}");    }}

Have a question or feedback? Here's how to reach us.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu