Multitenancy clarifications (#2668)

* Clarify tiered 1-shard limitation and update code snippets to show best practice

* Split write/read multitenancy section

* Use consistent example throughout the page

* Hide client initialization from all code snippets
This commit is contained in:
Abdon Pijpelink
2026-08-25 17:38:25 +02:00
committed by GitHub
parent 043c8462d5
commit cb392b6d16
130 changed files with 481 additions and 296 deletions
@@ -1,6 +1,4 @@
```python
from qdrant_client import QdrantClient, models
client.create_collection(
collection_name="{collection_name}",
shard_number=1,
@@ -1,6 +1,4 @@
```typescript
import { QdrantClient } from "@qdrant/js-client-rest";
client.createCollection("{collection_name}", {
shard_number: 1,
sharding_method: "custom",
@@ -1,4 +1,4 @@
from qdrant_client import QdrantClient, models
from qdrant_client import QdrantClient, models # @hide
# @hide-start
client = QdrantClient(url="http://localhost:6333")
@@ -1,4 +1,4 @@
import { QdrantClient } from "@qdrant/js-client-rest";
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
// @hide-start
const client = new QdrantClient({ host: "localhost", port: 6333 });
@@ -5,7 +5,7 @@ public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334);
var client = new QdrantClient("localhost", 6334); // @hide
await client.CreateCollectionAsync(
collectionName: "{collection_name}",
@@ -2,8 +2,6 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
var client = new QdrantClient("localhost", 6334);
await client.CreateCollectionAsync(
collectionName: "{collection_name}",
vectorsConfig: new VectorParams { Size = 768, Distance = Distance.Cosine },
@@ -5,11 +5,6 @@ import (
"github.com/qdrant/go-client/qdrant"
)
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
CollectionName: "{collection_name}",
VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{
@@ -7,9 +7,6 @@ import io.qdrant.client.grpc.Collections.HnswConfigDiff;
import io.qdrant.client.grpc.Collections.VectorParams;
import io.qdrant.client.grpc.Collections.VectorsConfig;
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
client
.createCollectionAsync(
CreateCollection.newBuilder()
@@ -1,8 +1,4 @@
```python
from qdrant_client import QdrantClient, models
client = QdrantClient(url="http://localhost:6333")
client.create_collection(
collection_name="{collection_name}",
vectors_config=models.VectorParams(size=768, distance=models.Distance.COSINE),
@@ -4,8 +4,6 @@ use qdrant_client::qdrant::{
};
use qdrant_client::Qdrant;
let client = Qdrant::from_url("http://localhost:6334").build()?;
client
.create_collection(
CreateCollectionBuilder::new("{collection_name}")
@@ -1,8 +1,4 @@
```typescript
import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
client.createCollection("{collection_name}", {
vectors: {
size: 768,
@@ -7,12 +7,14 @@ import (
)
func Main() {
// @hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil { panic(err) } // @hide
if err != nil { panic(err) }
// @hide-end
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
CollectionName: "{collection_name}",
@@ -10,8 +10,10 @@ import io.qdrant.client.grpc.Collections.VectorsConfig;
public class Snippet {
public static void run() throws Exception {
// @hide-start
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
// @hide-end
client
.createCollectionAsync(
@@ -1,6 +1,6 @@
from qdrant_client import QdrantClient, models
from qdrant_client import QdrantClient, models # @hide
client = QdrantClient(url="http://localhost:6333")
client = QdrantClient(url="http://localhost:6333") # @hide
client.create_collection(
collection_name="{collection_name}",
@@ -4,7 +4,7 @@ use qdrant_client::qdrant::{
use qdrant_client::Qdrant;
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
client
.create_collection(
@@ -1,6 +1,6 @@
import { QdrantClient } from "@qdrant/js-client-rest";
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 });
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.createCollection("{collection_name}", {
vectors: {
@@ -5,7 +5,7 @@ public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334);
var client = new QdrantClient("localhost", 6334); // @hide
await client.CreatePayloadIndexAsync(
collectionName: "{collection_name}",
@@ -2,8 +2,6 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
var client = new QdrantClient("localhost", 6334);
await client.CreatePayloadIndexAsync(
collectionName: "{collection_name}",
fieldName: "group_id",
@@ -5,11 +5,6 @@ import (
"github.com/qdrant/go-client/qdrant"
)
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
client.CreateFieldIndex(context.Background(), &qdrant.CreateFieldIndexCollection{
CollectionName: "{collection_name}",
FieldName: "group_id",
@@ -5,9 +5,6 @@ import io.qdrant.client.grpc.Collections.KeywordIndexParams;
import io.qdrant.client.grpc.Collections.PayloadIndexParams;
import io.qdrant.client.grpc.Collections.PayloadSchemaType;
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
client
.createPayloadIndexAsync(
"{collection_name}",
@@ -6,8 +6,6 @@ use qdrant_client::qdrant::{
};
use qdrant_client::Qdrant;
let client = Qdrant::from_url("http://localhost:6334").build()?;
client.create_field_index(
CreateFieldIndexCollectionBuilder::new(
"{collection_name}",
@@ -7,12 +7,14 @@ import (
)
func Main() {
// @hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil { panic(err) } // @hide
if err != nil { panic(err) }
// @hide-end
client.CreateFieldIndex(context.Background(), &qdrant.CreateFieldIndexCollection{
CollectionName: "{collection_name}",
@@ -8,8 +8,10 @@ import io.qdrant.client.grpc.Collections.PayloadSchemaType;
public class Snippet {
public static void run() throws Exception {
// @hide-start
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
// @hide-end
client
.createPayloadIndexAsync(
@@ -6,7 +6,7 @@ use qdrant_client::qdrant::{
use qdrant_client::Qdrant;
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
client.create_field_index(
CreateFieldIndexCollectionBuilder::new(
@@ -5,11 +5,11 @@ public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334);
var client = new QdrantClient("localhost", 6334); // @hide
await client.CreateShardKeyAsync(
"{collection_name}",
new CreateShardKey { ShardKey = new ShardKey { Keyword = "default", } }
new CreateShardKey { ShardKey = new ShardKey { Keyword = "default", }, ShardsNumber = 1 }
);
}
}
@@ -2,10 +2,8 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
var client = new QdrantClient("localhost", 6334);
await client.CreateShardKeyAsync(
"{collection_name}",
new CreateShardKey { ShardKey = new ShardKey { Keyword = "default", } }
new CreateShardKey { ShardKey = new ShardKey { Keyword = "default", }, ShardsNumber = 1 }
);
```
@@ -5,12 +5,8 @@ import (
"github.com/qdrant/go-client/qdrant"
)
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
client.CreateShardKey(context.Background(), "{collection_name}", &qdrant.CreateShardKey{
ShardKey: qdrant.NewShardKey("default"),
ShardKey: qdrant.NewShardKey("default"),
ShardsNumber: qdrant.PtrOf(uint32(1)),
})
```
@@ -6,13 +6,11 @@ import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Collections.CreateShardKey;
import io.qdrant.client.grpc.Collections.CreateShardKeyRequest;
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
client.createShardKeyAsync(CreateShardKeyRequest.newBuilder()
.setCollectionName("{collection_name}")
.setRequest(CreateShardKey.newBuilder()
.setShardKey(shardKey("default"))
.setShardsNumber(1)
.build())
.build()).get();
```
@@ -1,7 +1,3 @@
```python
from qdrant_client import QdrantClient, models
client = QdrantClient(url="http://localhost:6333")
client.create_shard_key("{collection_name}", "default")
client.create_shard_key("{collection_name}", "default", shards_number=1)
```
@@ -4,12 +4,10 @@ use qdrant_client::qdrant::{
};
use qdrant_client::Qdrant;
let client = Qdrant::from_url("http://localhost:6334").build()?;
client
.create_shard_key(
CreateShardKeyRequestBuilder::new("{collection_name}")
.request(CreateShardKeyBuilder::default().shard_key("default".to_string())),
.request(CreateShardKeyBuilder::default().shard_key("default".to_string()).shards_number(1)),
)
.await?;
```
@@ -1,9 +1,6 @@
```typescript
import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
client.createShardKey("{collection_name}", {
shard_key: "default"
shard_key: "default",
shards_number: 1
});
```
@@ -7,14 +7,17 @@ import (
)
func Main() {
// @hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil { panic(err) } // @hide
if err != nil { panic(err) }
// @hide-end
client.CreateShardKey(context.Background(), "{collection_name}", &qdrant.CreateShardKey{
ShardKey: qdrant.NewShardKey("default"),
ShardKey: qdrant.NewShardKey("default"),
ShardsNumber: qdrant.PtrOf(uint32(1)),
})
}
@@ -1,6 +1,7 @@
```http
PUT /collections/{collection_name}/shards
{
"shard_key": "default"
"shard_key": "default",
"shards_number": 1
}
```
@@ -9,13 +9,16 @@ import io.qdrant.client.grpc.Collections.CreateShardKeyRequest;
public class Snippet {
public static void run() throws Exception {
// @hide-start
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
// @hide-end
client.createShardKeyAsync(CreateShardKeyRequest.newBuilder()
.setCollectionName("{collection_name}")
.setRequest(CreateShardKey.newBuilder()
.setShardKey(shardKey("default"))
.setShardsNumber(1)
.build())
.build()).get();
}
@@ -1,5 +1,5 @@
from qdrant_client import QdrantClient, models
from qdrant_client import QdrantClient, models # @hide
client = QdrantClient(url="http://localhost:6333")
client = QdrantClient(url="http://localhost:6333") # @hide
client.create_shard_key("{collection_name}", "default")
client.create_shard_key("{collection_name}", "default", shards_number=1)
@@ -4,12 +4,12 @@ use qdrant_client::qdrant::{
use qdrant_client::Qdrant;
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
client
.create_shard_key(
CreateShardKeyRequestBuilder::new("{collection_name}")
.request(CreateShardKeyBuilder::default().shard_key("default".to_string())),
.request(CreateShardKeyBuilder::default().shard_key("default".to_string()).shards_number(1)),
)
.await?;
@@ -1,7 +1,8 @@
import { QdrantClient } from "@qdrant/js-client-rest";
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 });
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.createShardKey("{collection_name}", {
shard_key: "default"
shard_key: "default",
shards_number: 1
});
@@ -5,12 +5,14 @@ public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334);
var client = new QdrantClient("localhost", 6334); // @hide
await client.CreateShardKeyAsync(
"{collection_name}",
new CreateShardKey {
new CreateShardKey {
ShardKey = new ShardKey { Keyword = "default" },
ShardsNumber = 1,
ReplicationFactor = 1,
InitialState = ReplicaState.Partial
}
);
@@ -2,12 +2,12 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
var client = new QdrantClient("localhost", 6334);
await client.CreateShardKeyAsync(
"{collection_name}",
new CreateShardKey {
new CreateShardKey {
ShardKey = new ShardKey { Keyword = "default" },
ShardsNumber = 1,
ReplicationFactor = 1,
InitialState = ReplicaState.Partial
}
);
@@ -5,17 +5,14 @@ import (
"github.com/qdrant/go-client/qdrant"
)
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
client.CreateShardKey(
context.Background(),
"{collection_name}",
&qdrant.CreateShardKey{
ShardKey: qdrant.NewShardKey("default"),
InitialState: qdrant.PtrOf(qdrant.ReplicaState_Partial),
ShardKey: qdrant.NewShardKey("default"),
ShardsNumber: qdrant.PtrOf(uint32(1)),
ReplicationFactor: qdrant.PtrOf(uint32(1)),
InitialState: qdrant.PtrOf(qdrant.ReplicaState_Partial),
},
)
```
@@ -8,13 +8,12 @@ import io.qdrant.client.grpc.Collections.CreateShardKeyRequest;
import io.qdrant.client.grpc.Collections.ReplicaState;
import io.qdrant.client.grpc.Common.Filter;
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
client.createShardKeyAsync(CreateShardKeyRequest.newBuilder()
.setCollectionName("{collection_name}")
.setRequest(CreateShardKey.newBuilder()
.setShardKey(shardKey("default"))
.setShardsNumber(1)
.setReplicationFactor(1)
.setInitialState(ReplicaState.Partial)
.build())
.build()).get();
@@ -1,11 +1,9 @@
```python
from qdrant_client import QdrantClient, models
client = QdrantClient(url="http://localhost:6333")
client.create_shard_key(
"{collection_name}",
shard_key="user_1",
shards_number=1,
replication_factor=1,
initial_state=models.ReplicaState.PARTIAL
)
```
@@ -5,14 +5,14 @@ use qdrant_client::qdrant::{
use qdrant_client::qdrant::ReplicaState;
use qdrant_client::Qdrant;
let client = Qdrant::from_url("http://localhost:6334").build()?;
client
.create_shard_key(
CreateShardKeyRequestBuilder::new("{collection_name}")
.request(
CreateShardKeyBuilder::default()
.shard_key("user_1".to_string())
.shards_number(1)
.replication_factor(1)
.initial_state(ReplicaState::Partial)
),
)
@@ -1,10 +1,8 @@
```typescript
import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
client.createShardKey("{collection_name}", {
shard_key: "default",
shards_number: 1,
replication_factor: 1,
initial_state: "Partial"
});
```
@@ -7,19 +7,23 @@ import (
)
func Main() {
// @hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil { panic(err) } // @hide
if err != nil { panic(err) }
// @hide-end
client.CreateShardKey(
context.Background(),
"{collection_name}",
&qdrant.CreateShardKey{
ShardKey: qdrant.NewShardKey("default"),
InitialState: qdrant.PtrOf(qdrant.ReplicaState_Partial),
ShardKey: qdrant.NewShardKey("default"),
ShardsNumber: qdrant.PtrOf(uint32(1)),
ReplicationFactor: qdrant.PtrOf(uint32(1)),
InitialState: qdrant.PtrOf(qdrant.ReplicaState_Partial),
},
)
}
@@ -2,6 +2,8 @@
PUT /collections/{collection_name}/shards
{
"shard_key": "user_1",
"shards_number": 1,
"replication_factor": 1,
"initial_state": "Partial"
}
```
@@ -11,13 +11,17 @@ import io.qdrant.client.grpc.Common.Filter;
public class Snippet {
public static void run() throws Exception {
// @hide-start
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
// @hide-end
client.createShardKeyAsync(CreateShardKeyRequest.newBuilder()
.setCollectionName("{collection_name}")
.setRequest(CreateShardKey.newBuilder()
.setShardKey(shardKey("default"))
.setShardsNumber(1)
.setReplicationFactor(1)
.setInitialState(ReplicaState.Partial)
.build())
.build()).get();
@@ -1,9 +1,11 @@
from qdrant_client import QdrantClient, models
from qdrant_client import QdrantClient, models # @hide
client = QdrantClient(url="http://localhost:6333")
client = QdrantClient(url="http://localhost:6333") # @hide
client.create_shard_key(
"{collection_name}",
shard_key="user_1",
shards_number=1,
replication_factor=1,
initial_state=models.ReplicaState.PARTIAL
)
@@ -5,7 +5,7 @@ use qdrant_client::qdrant::ReplicaState;
use qdrant_client::Qdrant;
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
client
.create_shard_key(
@@ -13,6 +13,8 @@ pub async fn main() -> anyhow::Result<()> {
.request(
CreateShardKeyBuilder::default()
.shard_key("user_1".to_string())
.shards_number(1)
.replication_factor(1)
.initial_state(ReplicaState::Partial)
),
)
@@ -1,8 +1,10 @@
import { QdrantClient } from "@qdrant/js-client-rest";
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 });
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.createShardKey("{collection_name}", {
shard_key: "default",
shards_number: 1,
replication_factor: 1,
initial_state: "Partial"
});
@@ -1,5 +1,3 @@
```python
from qdrant_client import QdrantClient, models
client.create_shard_key("{collection_name}", "{shard_key}")
```
@@ -1,6 +1,4 @@
```typescript
import { QdrantClient } from "@qdrant/js-client-rest";
client.createShardKey("{collection_name}", {
shard_key: "{shard_key}"
});
@@ -1,4 +1,4 @@
from qdrant_client import QdrantClient, models
from qdrant_client import QdrantClient, models # @hide
# @hide-start
client = QdrantClient(url="http://localhost:6333")
@@ -1,4 +1,4 @@
import { QdrantClient } from "@qdrant/js-client-rest";
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
// @hide-start
const client = new QdrantClient({ host: "localhost", port: 6333 });
@@ -1,6 +1,4 @@
```python
from qdrant_client import QdrantClient, models
client.upsert(
collection_name="{collection_name}",
points=[
@@ -1,6 +1,4 @@
```typescript
import { QdrantClient } from "@qdrant/js-client-rest";
client.upsert("{collection_name}", {
points: [
{
@@ -1,4 +1,4 @@
from qdrant_client import QdrantClient, models
from qdrant_client import QdrantClient, models # @hide
# @hide-start
client = QdrantClient(url="http://localhost:6333")
@@ -1,4 +1,4 @@
import { QdrantClient } from "@qdrant/js-client-rest";
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
// @hide-start
const client = new QdrantClient({ host: "localhost", port: 6333 });
@@ -5,7 +5,7 @@ public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334);
var client = new QdrantClient("localhost", 6334); // @hide
await client.UpsertAsync(
collectionName: "{collection_name}",
@@ -2,8 +2,6 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
var client = new QdrantClient("localhost", 6334);
await client.UpsertAsync(
collectionName: "{collection_name}",
points: new List<PointStruct>
@@ -5,11 +5,6 @@ import (
"github.com/qdrant/go-client/qdrant"
)
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -12,9 +12,6 @@ import io.qdrant.client.grpc.Points.UpsertPoints;
import java.util.List;
import java.util.Map;
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
client
.upsertAsync(
UpsertPoints.newBuilder()
@@ -2,8 +2,6 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{PointStruct, ShardKeySelectorBuilder, UpsertPointsBuilder};
let client = Qdrant::from_url("http://localhost:6334").build()?;
let shard_key_selector = ShardKeySelectorBuilder::with_shard_key("user_1")
.fallback("default")
.build();
@@ -1,8 +1,4 @@
```typescript
import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
client.upsert("{collection_name}", {
points: [
{
@@ -7,12 +7,14 @@ import (
)
func Main() {
// @hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil { panic(err) } // @hide
if err != nil { panic(err) }
// @hide-end
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
@@ -15,8 +15,10 @@ import java.util.Map;
public class Snippet {
public static void run() throws Exception {
// @hide-start
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
// @hide-end
client
.upsertAsync(
@@ -2,7 +2,7 @@ use qdrant_client::Qdrant;
use qdrant_client::qdrant::{PointStruct, ShardKeySelectorBuilder, UpsertPointsBuilder};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
let shard_key_selector = ShardKeySelectorBuilder::with_shard_key("user_1")
.fallback("default")
@@ -1,6 +1,6 @@
import { QdrantClient } from "@qdrant/js-client-rest";
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 });
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.upsert("{collection_name}", {
points: [
@@ -5,7 +5,7 @@ public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334);
var client = new QdrantClient("localhost", 6334); // @hide
await client.UpsertAsync(
collectionName: "{collection_name}",
@@ -2,8 +2,6 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
var client = new QdrantClient("localhost", 6334);
await client.UpsertAsync(
collectionName: "{collection_name}",
points: new List<PointStruct>
@@ -5,11 +5,6 @@ import (
"github.com/qdrant/go-client/qdrant"
)
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
@@ -9,9 +9,6 @@ import io.qdrant.client.grpc.Points.PointStruct;
import java.util.List;
import java.util.Map;
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
client
.upsertAsync(
"{collection_name}",
@@ -2,8 +2,6 @@
use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
use qdrant_client::Qdrant;
let client = Qdrant::from_url("http://localhost:6334").build()?;
client
.upsert_points(UpsertPointsBuilder::new(
"{collection_name}",
@@ -1,8 +1,4 @@
```typescript
import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
client.upsert("{collection_name}", {
points: [
{
@@ -7,12 +7,14 @@ import (
)
func Main() {
// @hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil { panic(err) } // @hide
if err != nil { panic(err) }
// @hide-end
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
@@ -12,8 +12,10 @@ import java.util.Map;
public class Snippet {
public static void run() throws Exception {
// @hide-start
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
// @hide-end
client
.upsertAsync(
@@ -2,7 +2,7 @@ use qdrant_client::qdrant::{PointStruct, UpsertPointsBuilder};
use qdrant_client::Qdrant;
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
client
.upsert_points(UpsertPointsBuilder::new(
@@ -1,6 +1,6 @@
import { QdrantClient } from "@qdrant/js-client-rest";
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 });
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.upsert("{collection_name}", {
points: [
@@ -0,0 +1 @@
Query a collection using a shard key selector with fallback, and filter results by `group_id`. The shard key selector routes to the tenant's dedicated shard if it exists, or falls back to the shared shard.
@@ -0,0 +1,22 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;
using static Qdrant.Client.Grpc.Conditions;
public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334); // @hide
await client.QueryAsync(
collectionName: "{collection_name}",
query: new float[] { 0.1f, 0.1f, 0.9f },
filter: MatchKeyword("group_id", "user_1"),
shardKeySelector: new ShardKeySelector {
ShardKeys = { new List<ShardKey> { "user_1" } },
Fallback = new ShardKey { Keyword = "default" }
},
limit: 10
);
}
}
@@ -0,0 +1,16 @@
```csharp
using Qdrant.Client;
using Qdrant.Client.Grpc;
using static Qdrant.Client.Grpc.Conditions;
await client.QueryAsync(
collectionName: "{collection_name}",
query: new float[] { 0.1f, 0.1f, 0.9f },
filter: MatchKeyword("group_id", "user_1"),
shardKeySelector: new ShardKeySelector {
ShardKeys = { new List<ShardKey> { "user_1" } },
Fallback = new ShardKey { Keyword = "default" }
},
limit: 10
);
```
@@ -0,0 +1,21 @@
```go
import (
"context"
"github.com/qdrant/go-client/qdrant"
)
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.1, 0.1, 0.9),
Filter: &qdrant.Filter{
Must: []*qdrant.Condition{
qdrant.NewMatch("group_id", "user_1"),
},
},
ShardKeySelector: &qdrant.ShardKeySelector{
ShardKeys: []*qdrant.ShardKey{qdrant.NewShardKey("user_1")},
Fallback: qdrant.NewShardKey("default"),
},
})
```
@@ -0,0 +1,26 @@
```java
import static io.qdrant.client.ConditionFactory.matchKeyword;
import static io.qdrant.client.QueryFactory.nearest;
import static io.qdrant.client.ShardKeyFactory.shardKey;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Common.Filter;
import io.qdrant.client.grpc.Points.QueryPoints;
import io.qdrant.client.grpc.Points.ShardKeySelector;
client.queryAsync(
QueryPoints.newBuilder()
.setCollectionName("{collection_name}")
.setFilter(
Filter.newBuilder().addMust(matchKeyword("group_id", "user_1")).build())
.setQuery(nearest(0.1f, 0.1f, 0.9f))
.setLimit(10)
.setShardKeySelector(
ShardKeySelector.newBuilder()
.addShardKeys(shardKey("user_1"))
.setFallback(shardKey("default"))
.build())
.build())
.get();
```
@@ -0,0 +1,19 @@
```python
client.query_points(
collection_name="{collection_name}",
query=[0.1, 0.1, 0.9],
query_filter=models.Filter(
must=[
models.FieldCondition(
key="group_id",
match=models.MatchValue(value="user_1"),
)
]
),
shard_key_selector=models.ShardKeyWithFallback(
target="user_1",
fallback="default"
),
limit=10,
)
```
@@ -0,0 +1,21 @@
```rust
use qdrant_client::qdrant::{Condition, Filter, QueryPointsBuilder, ShardKeySelectorBuilder};
use qdrant_client::Qdrant;
let shard_key_selector = ShardKeySelectorBuilder::with_shard_key("user_1")
.fallback("default")
.build();
client
.query(
QueryPointsBuilder::new("{collection_name}")
.query(vec![0.1, 0.1, 0.9])
.limit(10)
.filter(Filter::must([Condition::matches(
"group_id",
"user_1".to_string(),
)]))
.shard_key_selector(shard_key_selector),
)
.await?;
```
@@ -0,0 +1,10 @@
```typescript
client.query("{collection_name}", {
query: [0.1, 0.1, 0.9],
filter: {
must: [{ key: "group_id", match: { value: "user_1" } }],
},
shard_key: { target: "user_1", fallback: "default" },
limit: 10,
});
```
@@ -0,0 +1,32 @@
package snippet
import (
"context"
"github.com/qdrant/go-client/qdrant"
)
func Main() {
// @hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil { panic(err) }
// @hide-end
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.1, 0.1, 0.9),
Filter: &qdrant.Filter{
Must: []*qdrant.Condition{
qdrant.NewMatch("group_id", "user_1"),
},
},
ShardKeySelector: &qdrant.ShardKeySelector{
ShardKeys: []*qdrant.ShardKey{qdrant.NewShardKey("user_1")},
Fallback: qdrant.NewShardKey("default"),
},
})
}
@@ -0,0 +1,21 @@
```http
POST /collections/{collection_name}/points/query
{
"query": [0.1, 0.1, 0.9],
"filter": {
"must": [
{
"key": "group_id",
"match": {
"value": "user_1"
}
}
]
},
"shard_key": {
"fallback": "default",
"target": "user_1"
},
"limit": 10
}
```
@@ -0,0 +1,35 @@
package com.example.snippets_amalgamation;
import static io.qdrant.client.ConditionFactory.matchKeyword;
import static io.qdrant.client.QueryFactory.nearest;
import static io.qdrant.client.ShardKeyFactory.shardKey;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Common.Filter;
import io.qdrant.client.grpc.Points.QueryPoints;
import io.qdrant.client.grpc.Points.ShardKeySelector;
public class Snippet {
public static void run() throws Exception {
// @hide-start
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
// @hide-end
client.queryAsync(
QueryPoints.newBuilder()
.setCollectionName("{collection_name}")
.setFilter(
Filter.newBuilder().addMust(matchKeyword("group_id", "user_1")).build())
.setQuery(nearest(0.1f, 0.1f, 0.9f))
.setLimit(10)
.setShardKeySelector(
ShardKeySelector.newBuilder()
.addShardKeys(shardKey("user_1"))
.setFallback(shardKey("default"))
.build())
.build())
.get();
}
}
@@ -0,0 +1,21 @@
from qdrant_client import QdrantClient, models # @hide
client = QdrantClient(url="http://localhost:6333") # @hide
client.query_points(
collection_name="{collection_name}",
query=[0.1, 0.1, 0.9],
query_filter=models.Filter(
must=[
models.FieldCondition(
key="group_id",
match=models.MatchValue(value="user_1"),
)
]
),
shard_key_selector=models.ShardKeyWithFallback(
target="user_1",
fallback="default"
),
limit=10,
)
@@ -0,0 +1,25 @@
use qdrant_client::qdrant::{Condition, Filter, QueryPointsBuilder, ShardKeySelectorBuilder};
use qdrant_client::Qdrant;
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
let shard_key_selector = ShardKeySelectorBuilder::with_shard_key("user_1")
.fallback("default")
.build();
client
.query(
QueryPointsBuilder::new("{collection_name}")
.query(vec![0.1, 0.1, 0.9])
.limit(10)
.filter(Filter::must([Condition::matches(
"group_id",
"user_1".to_string(),
)]))
.shard_key_selector(shard_key_selector),
)
.await?;
Ok(())
}
@@ -0,0 +1,12 @@
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
client.query("{collection_name}", {
query: [0.1, 0.1, 0.9],
filter: {
must: [{ key: "group_id", match: { value: "user_1" } }],
},
shard_key: { target: "user_1", fallback: "default" },
limit: 10,
});
@@ -6,7 +6,7 @@ public class Snippet
{
public static async Task Run()
{
var client = new QdrantClient("localhost", 6334);
var client = new QdrantClient("localhost", 6334); // @hide
await client.QueryAsync(
collectionName: "{collection_name}",
@@ -3,8 +3,6 @@ using Qdrant.Client;
using Qdrant.Client.Grpc;
using static Qdrant.Client.Grpc.Conditions;
var client = new QdrantClient("localhost", 6334);
await client.QueryAsync(
collectionName: "{collection_name}",
query: new float[] { 0.1f, 0.1f, 0.9f },
@@ -5,11 +5,6 @@ import (
"github.com/qdrant/go-client/qdrant"
)
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.1, 0.1, 0.9),
@@ -8,9 +8,6 @@ import io.qdrant.client.grpc.Common.Filter;
import io.qdrant.client.grpc.Points.QueryPoints;
import java.util.List;
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
client.queryAsync(
QueryPoints.newBuilder()
.setCollectionName("{collection_name}")
@@ -1,8 +1,4 @@
```python
from qdrant_client import QdrantClient, models
client = QdrantClient(url="http://localhost:6333")
client.query_points(
collection_name="{collection_name}",
query=[0.1, 0.1, 0.9],
@@ -2,8 +2,6 @@
use qdrant_client::qdrant::{Condition, Filter, QueryPointsBuilder};
use qdrant_client::Qdrant;
let client = Qdrant::from_url("http://localhost:6334").build()?;
client
.query(
QueryPointsBuilder::new("{collection_name}")
@@ -1,8 +1,4 @@
```typescript
import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
client.query("{collection_name}", {
query: [0.1, 0.1, 0.9],
filter: {
@@ -7,12 +7,14 @@ import (
)
func Main() {
// @hide-start
client, err := qdrant.NewClient(&qdrant.Config{
Host: "localhost",
Port: 6334,
})
if err != nil { panic(err) } // @hide
if err != nil { panic(err) }
// @hide-end
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",

Some files were not shown because too many files have changed in this diff Show More