Multi-node setup
Replication settings
Section titled “Replication settings”Configure replication settings, such as async replication and deletion resolution strategy.
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, ), ),)import { configure } from 'weaviate-client';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,
},
}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))))));await client.Collections.Create(
new CollectionCreateParams
{
Name = "Article",
ReplicationConfig = new ReplicationConfig
{
Factor = 1,
AsyncEnabled = true,
DeletionStrategy = DeletionStrategy.TimeBasedResolution,
},
}
);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/schemaAdditional information
To use replication factors greater than one, use a multi-node deployment.
For details on the configuration parameters, see the following:
Update replication settings
Section titled “Update replication settings”Update async replication settings for an existing collection. The asyncConfig parameters are mutable and can be changed at any time.
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, ), ),)const articleReplication = replicationClient.collections.use('Article')await articleReplication.config.update({ replication: reconfigure.replication({ asyncConfig: { frequency: 60, }, }),})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))))));Sharding settings
Section titled “Sharding settings”Configure sharding per collection.
from weaviate.classes.config import Configureclient.collections.create( "Article", sharding_config=Configure.sharding( virtual_per_physical=128, desired_count=1, desired_virtual_count=128, ),)import { configure } from 'weaviate-client';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,
},
}client.collections.create("Article",
col -> col.sharding(Sharding.of(s -> s.virtualPerPhysical(128)
.desiredCount(1)
.desiredVirtualCount(128))));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:
Inspect shards (for a collection)
Section titled “Inspect shards (for a collection)”An index itself can be comprised of multiple shards.
articles = client.collections.use("Article")article_shards = articles.config.get_shards()print(article_shards)let articles = client.collections.use('Article')const shards = await articles.config.getShards()console.log(JSON.stringify(shards, null, 2));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)
}CollectionHandle<Map<String, Object>> articles =
client.collections.use("Article");
List<Shard> articleShards = articles.config.getShards();
System.out.println(articleShards);// Coming soonUpdate shard status
Section titled “Update shard status”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.
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)let articles = client.collections.use("Article");const shards = await articles.config.updateShards("READY", "shard-1234");console.log(JSON.stringify(shards, null, 2));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)CollectionHandle<Map<String, Object>> articles =
client.collections.use("Article");
List<Shard> articleShards =
articles.config.updateShards(ShardStatus.READONLY, shardName);
System.out.println(articleShards);// Coming soonFurther resources
Section titled “Further resources”Questions and feedback
Section titled “Questions and feedback”Have a question or feedback? Here's how to reach us.