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

Search documentation

Type to search this documentation.

On this pageOverview

Multi-node setup

Configure replication settings, such as async replication and deletion resolution strategy.

Python
from weaviate.classes.config import Configure, ReplicationDeletionStrategyclient.collections.create(    "Article",    replication_config=Configure.replication(        factor=3,        deletion_strategy=ReplicationDeletionStrategy.TIME_BASED_RESOLUTION,        async_config=Configure.Replication.async_config(            hashtree_height=16,            frequency=30,        ),    ),)
JavaScript/TypeScript
import { configure } from 'weaviate-client';
Go
articleClass := &models.Class{
  Class:       "Article",
  Description: "Collection of articles",
  // Async replication runs by default when the replication factor is greater than 1
  ReplicationConfig: &models.ReplicationConfig{
    Factor:           3,
    DeletionStrategy: models.ReplicationConfigDeletionStrategyTimeBasedResolution,
  },
}
Java
threeNodeClient.collections.create("Article",
    col -> col.replication(Replication.of(rep -> rep.replicationFactor(3)
        .deletionStrategy(DeletionStrategy.TIME_BASED_RESOLUTION)
        .asyncReplication(AsyncReplicationConfig.of(async -> async
            .propagationConcurrency(5)
            .hashTreeHeight(16)
            .frequencyMillis(30))))));
C#
await client.Collections.Create(
    new CollectionCreateParams
    {
        Name = "Article",
        ReplicationConfig = new ReplicationConfig
        {
            Factor = 1,
            AsyncEnabled = true,
            DeletionStrategy = DeletionStrategy.TimeBasedResolution,
        },
    }
);
cURL
curl \
-X POST \
-H "Content-Type: application/json" \
-d '{
    "class": "Article",
    "properties": [
        {
            "dataType": [
                "string"
            ],
            "description": "Title of the article",
            "name": "title"
        }
    ],
    "replicationConfig": {
      "factor": 3,
      "deletionStrategy": "TimeBasedResolution",
      "asyncConfig": {
        "hashtreeHeight": 16,
        "frequency": 30000
      }
    }
}' \
http://localhost:8080/v1/schema
Additional information

To use replication factors greater than one, use a multi-node deployment.

For details on the configuration parameters, see the following:

Update async replication settings for an existing collection. The asyncConfig parameters are mutable and can be changed at any time.

Python
from weaviate.classes.config import Reconfigurecollection = client.collections.get("Article")collection.config.update(    replication_config=Reconfigure.replication(        async_config=Reconfigure.Replication.async_config(            frequency=60,        ),    ),)
JavaScript/TypeScript
const articleReplication = replicationClient.collections.use('Article')await articleReplication.config.update({  replication: reconfigure.replication({    asyncConfig: {      frequency: 60,    },  }),})
Java
var collection = threeNodeClient.collections.use("Article");collection.config.update(col -> col.replication(Replication.of(    rep -> rep.asyncReplication(AsyncReplicationConfig.of(async -> async        .propagationConcurrency(10)        .frequencyMillis(60))))));

Configure sharding per collection.

Python
from weaviate.classes.config import Configureclient.collections.create(    "Article",    sharding_config=Configure.sharding(        virtual_per_physical=128,        desired_count=1,        desired_virtual_count=128,    ),)
JavaScript/TypeScript
import { configure } from 'weaviate-client';
Go
articleClass := &models.Class{
  Class:       "Article",
  Description: "Collection of articles",
  ShardingConfig: sharding.Config{
    VirtualPerPhysical:  128,
    DesiredCount:        1,
    DesiredVirtualCount: 128,
    Key:                 sharding.DefaultKey,
    Strategy:            sharding.DefaultStrategy,
    Function:            sharding.DefaultFunction,
  },
}
Java
client.collections.create("Article",
    col -> col.sharding(Sharding.of(s -> s.virtualPerPhysical(128)
        .desiredCount(1)
        .desiredVirtualCount(128))));
C#
await client.Collections.Create(
    new CollectionCreateParams
    {
        Name = "Article",
        ShardingConfig = new ShardingConfig
        {
            VirtualPerPhysical = 128,
            DesiredCount = 1,
            DesiredVirtualCount = 128,
        },
    }
);
Additional information

For details on the configuration parameters, see the following:

An index itself can be comprised of multiple shards.

Python
articles = client.collections.use("Article")article_shards = articles.config.get_shards()print(article_shards)
JavaScript/TypeScript
let articles = client.collections.use('Article')const shards = await articles.config.getShards()console.log(JSON.stringify(shards, null, 2));
Go
package main

import (
  "context"
  "fmt"

  "github.com/weaviate/weaviate-go-client/v5/weaviate"
)

func main() {
  cfg := weaviate.Config{
    Host:   "localhost:8080",
    Scheme: "http",
  }
  client, err := weaviate.NewClient(cfg)
  if err != nil {
    panic(err)
  }
  shards, err := client.Schema().
    ShardsGetter().
    WithClassName("Article").
    Do(context.Background())
  if err != nil {
    panic(err)
  }
  fmt.Printf("%v", shards)
}
Java
CollectionHandle<Map<String, Object>> articles =
    client.collections.use("Article");

List<Shard> articleShards = articles.config.getShards();
System.out.println(articleShards);
C#
// Coming soon

You can manually update a shard to change it's status. For example, update the shard status from READONLY to READY after you make other changes.

Python
articles = client.collections.use("Article")article_shards = articles.config.update_shards(    status="READY",    shard_names=shard_names,  # The names (List[str]) of the shard to update (or a shard name))print(article_shards)
JavaScript/TypeScript
let articles = client.collections.use("Article");const shards = await articles.config.updateShards("READY", "shard-1234");console.log(JSON.stringify(shards, null, 2));
Go
shardStatus, err := client.Schema().ShardUpdater().
  WithClassName(myCollectionName). // Set your collection name
  WithShardName(shardName).        // Set the shard name to update
  WithStatus("READY").
  Do(ctx)
if err != nil {
  // handle error
  panic(err)
}
fmt.Printf("%v", shardStatus)
Java
CollectionHandle<Map<String, Object>> articles =
    client.collections.use("Article");

List<Shard> articleShards =
    articles.config.updateShards(ShardStatus.READONLY, shardName);
System.out.println(articleShards);
C#
// Coming soon

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