mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-09 12:58:31 +02:00
Create code snippets for distributed deployment.
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
This code snippet creates a collection with shard replication by setting `shard_number` to 6 and `replication_factor` to 2. Each shard is stored on two nodes, which improves resilience and availability when a node goes down.
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
public class Snippet
|
||||
{
|
||||
public static async Task Run()
|
||||
{
|
||||
// @hide-start
|
||||
var client = new QdrantClient("localhost", 6334);
|
||||
// @hide-end
|
||||
|
||||
await client.CreateCollectionAsync(
|
||||
collectionName: "{collection_name}",
|
||||
vectorsConfig: new VectorParams { Size = 300, Distance = Distance.Cosine },
|
||||
shardNumber: 6,
|
||||
replicationFactor: 2
|
||||
);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
```csharp
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
await client.CreateCollectionAsync(
|
||||
collectionName: "{collection_name}",
|
||||
vectorsConfig: new VectorParams { Size = 300, Distance = Distance.Cosine },
|
||||
shardNumber: 6,
|
||||
replicationFactor: 2
|
||||
);
|
||||
```
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
```go
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/qdrant/go-client/qdrant"
|
||||
)
|
||||
|
||||
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
|
||||
CollectionName: "{collection_name}",
|
||||
VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{
|
||||
Size: 300,
|
||||
Distance: qdrant.Distance_Cosine,
|
||||
}),
|
||||
ShardNumber: qdrant.PtrOf(uint32(6)),
|
||||
ReplicationFactor: qdrant.PtrOf(uint32(2)),
|
||||
})
|
||||
```
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
```java
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Collections.CreateCollection;
|
||||
import io.qdrant.client.grpc.Collections.Distance;
|
||||
import io.qdrant.client.grpc.Collections.VectorParams;
|
||||
import io.qdrant.client.grpc.Collections.VectorsConfig;
|
||||
|
||||
client
|
||||
.createCollectionAsync(
|
||||
CreateCollection.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.setVectorsConfig(
|
||||
VectorsConfig.newBuilder()
|
||||
.setParams(
|
||||
VectorParams.newBuilder()
|
||||
.setSize(300)
|
||||
.setDistance(Distance.Cosine)
|
||||
.build())
|
||||
.build())
|
||||
.setShardNumber(6)
|
||||
.setReplicationFactor(2)
|
||||
.build())
|
||||
.get();
|
||||
```
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
```python
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
client.create_collection(
|
||||
collection_name="{collection_name}",
|
||||
vectors_config=models.VectorParams(size=300, distance=models.Distance.COSINE),
|
||||
shard_number=6,
|
||||
replication_factor=2,
|
||||
)
|
||||
```
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
```rust
|
||||
use qdrant_client::qdrant::{CreateCollectionBuilder, Distance, VectorParamsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
client
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(300, Distance::Cosine))
|
||||
.shard_number(6)
|
||||
.replication_factor(2),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
```typescript
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
client.createCollection("{collection_name}", {
|
||||
vectors: {
|
||||
size: 300,
|
||||
distance: "Cosine",
|
||||
},
|
||||
shard_number: 6,
|
||||
replication_factor: 2,
|
||||
});
|
||||
```
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
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.CreateCollection(context.Background(), &qdrant.CreateCollection{
|
||||
CollectionName: "{collection_name}",
|
||||
VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{
|
||||
Size: 300,
|
||||
Distance: qdrant.Distance_Cosine,
|
||||
}),
|
||||
ShardNumber: qdrant.PtrOf(uint32(6)),
|
||||
ReplicationFactor: qdrant.PtrOf(uint32(2)),
|
||||
})
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
```http
|
||||
PUT /collections/{collection_name}
|
||||
{
|
||||
"vectors": {
|
||||
"size": 300,
|
||||
"distance": "Cosine"
|
||||
},
|
||||
"shard_number": 6,
|
||||
"replication_factor": 2
|
||||
}
|
||||
```
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.example.snippets_amalgamation;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Collections.CreateCollection;
|
||||
import io.qdrant.client.grpc.Collections.Distance;
|
||||
import io.qdrant.client.grpc.Collections.VectorParams;
|
||||
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(
|
||||
CreateCollection.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.setVectorsConfig(
|
||||
VectorsConfig.newBuilder()
|
||||
.setParams(
|
||||
VectorParams.newBuilder()
|
||||
.setSize(300)
|
||||
.setDistance(Distance.Cosine)
|
||||
.build())
|
||||
.build())
|
||||
.setShardNumber(6)
|
||||
.setReplicationFactor(2)
|
||||
.build())
|
||||
.get();
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
# @hide-start
|
||||
client = QdrantClient(url="http://localhost:6333")
|
||||
# @hide-end
|
||||
|
||||
client.create_collection(
|
||||
collection_name="{collection_name}",
|
||||
vectors_config=models.VectorParams(size=300, distance=models.Distance.COSINE),
|
||||
shard_number=6,
|
||||
replication_factor=2,
|
||||
)
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
use qdrant_client::qdrant::{CreateCollectionBuilder, Distance, VectorParamsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
pub async fn main() -> anyhow::Result<()> {
|
||||
// @hide-start
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
// @hide-end
|
||||
|
||||
client
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(300, Distance::Cosine))
|
||||
.shard_number(6)
|
||||
.replication_factor(2),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
// @hide-start
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
// @hide-end
|
||||
|
||||
client.createCollection("{collection_name}", {
|
||||
vectors: {
|
||||
size: 300,
|
||||
distance: "Cosine",
|
||||
},
|
||||
shard_number: 6,
|
||||
replication_factor: 2,
|
||||
});
|
||||
+1
@@ -0,0 +1 @@
|
||||
This code snippet creates a collection split into a specific number of shards by setting `shard_number` to 6. The shard count determines how the collection's data is distributed across nodes and cannot be changed without recreating the collection.
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
public class Snippet
|
||||
{
|
||||
public static async Task Run()
|
||||
{
|
||||
// @hide-start
|
||||
var client = new QdrantClient("localhost", 6334);
|
||||
// @hide-end
|
||||
|
||||
await client.CreateCollectionAsync(
|
||||
collectionName: "{collection_name}",
|
||||
vectorsConfig: new VectorParams { Size = 300, Distance = Distance.Cosine },
|
||||
shardNumber: 6
|
||||
);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
```csharp
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
await client.CreateCollectionAsync(
|
||||
collectionName: "{collection_name}",
|
||||
vectorsConfig: new VectorParams { Size = 300, Distance = Distance.Cosine },
|
||||
shardNumber: 6
|
||||
);
|
||||
```
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
```go
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/qdrant/go-client/qdrant"
|
||||
)
|
||||
|
||||
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
|
||||
CollectionName: "{collection_name}",
|
||||
VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{
|
||||
Size: 300,
|
||||
Distance: qdrant.Distance_Cosine,
|
||||
}),
|
||||
ShardNumber: qdrant.PtrOf(uint32(6)),
|
||||
})
|
||||
```
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
```java
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Collections.CreateCollection;
|
||||
import io.qdrant.client.grpc.Collections.Distance;
|
||||
import io.qdrant.client.grpc.Collections.VectorParams;
|
||||
import io.qdrant.client.grpc.Collections.VectorsConfig;
|
||||
|
||||
client
|
||||
.createCollectionAsync(
|
||||
CreateCollection.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.setVectorsConfig(
|
||||
VectorsConfig.newBuilder()
|
||||
.setParams(
|
||||
VectorParams.newBuilder()
|
||||
.setSize(300)
|
||||
.setDistance(Distance.Cosine)
|
||||
.build())
|
||||
.build())
|
||||
.setShardNumber(6)
|
||||
.build())
|
||||
.get();
|
||||
```
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
```python
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
client.create_collection(
|
||||
collection_name="{collection_name}",
|
||||
vectors_config=models.VectorParams(size=300, distance=models.Distance.COSINE),
|
||||
shard_number=6,
|
||||
)
|
||||
```
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
```rust
|
||||
use qdrant_client::qdrant::{CreateCollectionBuilder, Distance, VectorParamsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
client
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(300, Distance::Cosine))
|
||||
.shard_number(6),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
```typescript
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
client.createCollection("{collection_name}", {
|
||||
vectors: {
|
||||
size: 300,
|
||||
distance: "Cosine",
|
||||
},
|
||||
shard_number: 6,
|
||||
});
|
||||
```
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
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.CreateCollection(context.Background(), &qdrant.CreateCollection{
|
||||
CollectionName: "{collection_name}",
|
||||
VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{
|
||||
Size: 300,
|
||||
Distance: qdrant.Distance_Cosine,
|
||||
}),
|
||||
ShardNumber: qdrant.PtrOf(uint32(6)),
|
||||
})
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
```http
|
||||
PUT /collections/{collection_name}
|
||||
{
|
||||
"vectors": {
|
||||
"size": 300,
|
||||
"distance": "Cosine"
|
||||
},
|
||||
"shard_number": 6
|
||||
}
|
||||
```
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.example.snippets_amalgamation;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Collections.CreateCollection;
|
||||
import io.qdrant.client.grpc.Collections.Distance;
|
||||
import io.qdrant.client.grpc.Collections.VectorParams;
|
||||
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(
|
||||
CreateCollection.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.setVectorsConfig(
|
||||
VectorsConfig.newBuilder()
|
||||
.setParams(
|
||||
VectorParams.newBuilder()
|
||||
.setSize(300)
|
||||
.setDistance(Distance.Cosine)
|
||||
.build())
|
||||
.build())
|
||||
.setShardNumber(6)
|
||||
.build())
|
||||
.get();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
# @hide-start
|
||||
client = QdrantClient(url="http://localhost:6333")
|
||||
# @hide-end
|
||||
|
||||
client.create_collection(
|
||||
collection_name="{collection_name}",
|
||||
vectors_config=models.VectorParams(size=300, distance=models.Distance.COSINE),
|
||||
shard_number=6,
|
||||
)
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
use qdrant_client::qdrant::{CreateCollectionBuilder, Distance, VectorParamsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
pub async fn main() -> anyhow::Result<()> {
|
||||
// @hide-start
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
// @hide-end
|
||||
|
||||
client
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(300, Distance::Cosine))
|
||||
.shard_number(6),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
// @hide-start
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
// @hide-end
|
||||
|
||||
client.createCollection("{collection_name}", {
|
||||
vectors: {
|
||||
size: 300,
|
||||
distance: "Cosine",
|
||||
},
|
||||
shard_number: 6,
|
||||
});
|
||||
+1
@@ -0,0 +1 @@
|
||||
This code snippet creates a collection configured for stronger write guarantees. It sets `shard_number` to 6, `replication_factor` to 2, and `write_consistency_factor` to 2, so a write operation is only acknowledged once the specified number of replicas confirm it.
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
public class Snippet
|
||||
{
|
||||
public static async Task Run()
|
||||
{
|
||||
// @hide-start
|
||||
var client = new QdrantClient("localhost", 6334);
|
||||
// @hide-end
|
||||
|
||||
await client.CreateCollectionAsync(
|
||||
collectionName: "{collection_name}",
|
||||
vectorsConfig: new VectorParams { Size = 300, Distance = Distance.Cosine },
|
||||
shardNumber: 6,
|
||||
replicationFactor: 2,
|
||||
writeConsistencyFactor: 2
|
||||
);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
```csharp
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
await client.CreateCollectionAsync(
|
||||
collectionName: "{collection_name}",
|
||||
vectorsConfig: new VectorParams { Size = 300, Distance = Distance.Cosine },
|
||||
shardNumber: 6,
|
||||
replicationFactor: 2,
|
||||
writeConsistencyFactor: 2
|
||||
);
|
||||
```
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
```go
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/qdrant/go-client/qdrant"
|
||||
)
|
||||
|
||||
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
|
||||
CollectionName: "{collection_name}",
|
||||
VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{
|
||||
Size: 300,
|
||||
Distance: qdrant.Distance_Cosine,
|
||||
}),
|
||||
ShardNumber: qdrant.PtrOf(uint32(6)),
|
||||
ReplicationFactor: qdrant.PtrOf(uint32(2)),
|
||||
WriteConsistencyFactor: qdrant.PtrOf(uint32(2)),
|
||||
})
|
||||
```
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
```java
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Collections.CreateCollection;
|
||||
import io.qdrant.client.grpc.Collections.Distance;
|
||||
import io.qdrant.client.grpc.Collections.VectorParams;
|
||||
import io.qdrant.client.grpc.Collections.VectorsConfig;
|
||||
|
||||
client
|
||||
.createCollectionAsync(
|
||||
CreateCollection.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.setVectorsConfig(
|
||||
VectorsConfig.newBuilder()
|
||||
.setParams(
|
||||
VectorParams.newBuilder()
|
||||
.setSize(300)
|
||||
.setDistance(Distance.Cosine)
|
||||
.build())
|
||||
.build())
|
||||
.setShardNumber(6)
|
||||
.setReplicationFactor(2)
|
||||
.setWriteConsistencyFactor(2)
|
||||
.build())
|
||||
.get();
|
||||
```
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
```python
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
client.create_collection(
|
||||
collection_name="{collection_name}",
|
||||
vectors_config=models.VectorParams(size=300, distance=models.Distance.COSINE),
|
||||
shard_number=6,
|
||||
replication_factor=2,
|
||||
write_consistency_factor=2,
|
||||
)
|
||||
```
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
```rust
|
||||
use qdrant_client::qdrant::{CreateCollectionBuilder, Distance, VectorParamsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
client
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(300, Distance::Cosine))
|
||||
.shard_number(6)
|
||||
.replication_factor(2)
|
||||
.write_consistency_factor(2),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
```typescript
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
client.createCollection("{collection_name}", {
|
||||
vectors: {
|
||||
size: 300,
|
||||
distance: "Cosine",
|
||||
},
|
||||
shard_number: 6,
|
||||
replication_factor: 2,
|
||||
write_consistency_factor: 2,
|
||||
});
|
||||
```
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
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.CreateCollection(context.Background(), &qdrant.CreateCollection{
|
||||
CollectionName: "{collection_name}",
|
||||
VectorsConfig: qdrant.NewVectorsConfig(&qdrant.VectorParams{
|
||||
Size: 300,
|
||||
Distance: qdrant.Distance_Cosine,
|
||||
}),
|
||||
ShardNumber: qdrant.PtrOf(uint32(6)),
|
||||
ReplicationFactor: qdrant.PtrOf(uint32(2)),
|
||||
WriteConsistencyFactor: qdrant.PtrOf(uint32(2)),
|
||||
})
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
```http
|
||||
PUT /collections/{collection_name}
|
||||
{
|
||||
"vectors": {
|
||||
"size": 300,
|
||||
"distance": "Cosine"
|
||||
},
|
||||
"shard_number": 6,
|
||||
"replication_factor": 2,
|
||||
"write_consistency_factor": 2
|
||||
}
|
||||
```
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.example.snippets_amalgamation;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Collections.CreateCollection;
|
||||
import io.qdrant.client.grpc.Collections.Distance;
|
||||
import io.qdrant.client.grpc.Collections.VectorParams;
|
||||
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(
|
||||
CreateCollection.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.setVectorsConfig(
|
||||
VectorsConfig.newBuilder()
|
||||
.setParams(
|
||||
VectorParams.newBuilder()
|
||||
.setSize(300)
|
||||
.setDistance(Distance.Cosine)
|
||||
.build())
|
||||
.build())
|
||||
.setShardNumber(6)
|
||||
.setReplicationFactor(2)
|
||||
.setWriteConsistencyFactor(2)
|
||||
.build())
|
||||
.get();
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
# @hide-start
|
||||
client = QdrantClient(url="http://localhost:6333")
|
||||
# @hide-end
|
||||
|
||||
client.create_collection(
|
||||
collection_name="{collection_name}",
|
||||
vectors_config=models.VectorParams(size=300, distance=models.Distance.COSINE),
|
||||
shard_number=6,
|
||||
replication_factor=2,
|
||||
write_consistency_factor=2,
|
||||
)
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
use qdrant_client::qdrant::{CreateCollectionBuilder, Distance, VectorParamsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
pub async fn main() -> anyhow::Result<()> {
|
||||
// @hide-start
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
// @hide-end
|
||||
|
||||
client
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(300, Distance::Cosine))
|
||||
.shard_number(6)
|
||||
.replication_factor(2)
|
||||
.write_consistency_factor(2),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
// @hide-start
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
// @hide-end
|
||||
|
||||
client.createCollection("{collection_name}", {
|
||||
vectors: {
|
||||
size: 300,
|
||||
distance: "Cosine",
|
||||
},
|
||||
shard_number: 6,
|
||||
replication_factor: 2,
|
||||
write_consistency_factor: 2,
|
||||
});
|
||||
+1
@@ -0,0 +1 @@
|
||||
This code snippet upserts a batch of points with a write `ordering` of `strong`. Qdrant routes the operation through the permanent shard leader so that all writes issued with the same ordering are applied and observed sequentially across replicas.
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
public class Snippet
|
||||
{
|
||||
public static async Task Run()
|
||||
{
|
||||
// @hide-start
|
||||
var client = new QdrantClient("localhost", 6334);
|
||||
// @hide-end
|
||||
|
||||
await client.UpsertAsync(
|
||||
collectionName: "{collection_name}",
|
||||
points: new List<PointStruct>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Id = 1,
|
||||
Vectors = new[] { 0.9f, 0.1f, 0.1f },
|
||||
Payload = { ["color"] = "red" }
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 2,
|
||||
Vectors = new[] { 0.1f, 0.9f, 0.1f },
|
||||
Payload = { ["color"] = "green" }
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 3,
|
||||
Vectors = new[] { 0.1f, 0.1f, 0.9f },
|
||||
Payload = { ["color"] = "blue" }
|
||||
}
|
||||
},
|
||||
ordering: WriteOrderingType.Strong
|
||||
);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
```csharp
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
await client.UpsertAsync(
|
||||
collectionName: "{collection_name}",
|
||||
points: new List<PointStruct>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Id = 1,
|
||||
Vectors = new[] { 0.9f, 0.1f, 0.1f },
|
||||
Payload = { ["color"] = "red" }
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 2,
|
||||
Vectors = new[] { 0.1f, 0.9f, 0.1f },
|
||||
Payload = { ["color"] = "green" }
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 3,
|
||||
Vectors = new[] { 0.1f, 0.1f, 0.9f },
|
||||
Payload = { ["color"] = "blue" }
|
||||
}
|
||||
},
|
||||
ordering: WriteOrderingType.Strong
|
||||
);
|
||||
```
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
```go
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/qdrant/go-client/qdrant"
|
||||
)
|
||||
|
||||
client.Upsert(context.Background(), &qdrant.UpsertPoints{
|
||||
CollectionName: "{collection_name}",
|
||||
Points: []*qdrant.PointStruct{
|
||||
{
|
||||
Id: qdrant.NewIDNum(1),
|
||||
Vectors: qdrant.NewVectors(0.9, 0.1, 0.1),
|
||||
Payload: qdrant.NewValueMap(map[string]any{"color": "red"}),
|
||||
},
|
||||
{
|
||||
Id: qdrant.NewIDNum(2),
|
||||
Vectors: qdrant.NewVectors(0.1, 0.9, 0.1),
|
||||
Payload: qdrant.NewValueMap(map[string]any{"color": "green"}),
|
||||
},
|
||||
{
|
||||
Id: qdrant.NewIDNum(3),
|
||||
Vectors: qdrant.NewVectors(0.1, 0.1, 0.9),
|
||||
Payload: qdrant.NewValueMap(map[string]any{"color": "blue"}),
|
||||
},
|
||||
},
|
||||
Ordering: &qdrant.WriteOrdering{
|
||||
Type: qdrant.WriteOrderingType_Strong,
|
||||
},
|
||||
})
|
||||
```
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
```java
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.qdrant.client.PointIdFactory.id;
|
||||
import static io.qdrant.client.ValueFactory.value;
|
||||
import static io.qdrant.client.VectorsFactory.vectors;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Points.PointStruct;
|
||||
import io.qdrant.client.grpc.Points.UpsertPoints;
|
||||
import io.qdrant.client.grpc.Points.WriteOrdering;
|
||||
import io.qdrant.client.grpc.Points.WriteOrderingType;
|
||||
|
||||
client
|
||||
.upsertAsync(
|
||||
UpsertPoints.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.addAllPoints(
|
||||
List.of(
|
||||
PointStruct.newBuilder()
|
||||
.setId(id(1))
|
||||
.setVectors(vectors(0.9f, 0.1f, 0.1f))
|
||||
.putAllPayload(Map.of("color", value("red")))
|
||||
.build(),
|
||||
PointStruct.newBuilder()
|
||||
.setId(id(2))
|
||||
.setVectors(vectors(0.1f, 0.9f, 0.1f))
|
||||
.putAllPayload(Map.of("color", value("green")))
|
||||
.build(),
|
||||
PointStruct.newBuilder()
|
||||
.setId(id(3))
|
||||
.setVectors(vectors(0.1f, 0.1f, 0.9f))
|
||||
.putAllPayload(Map.of("color", value("blue")))
|
||||
.build()))
|
||||
.setOrdering(WriteOrdering.newBuilder().setType(WriteOrderingType.Strong).build())
|
||||
.build())
|
||||
.get();
|
||||
```
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
```python
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
client.upsert(
|
||||
collection_name="{collection_name}",
|
||||
points=models.Batch(
|
||||
ids=[1, 2, 3],
|
||||
payloads=[
|
||||
{"color": "red"},
|
||||
{"color": "green"},
|
||||
{"color": "blue"},
|
||||
],
|
||||
vectors=[
|
||||
[0.9, 0.1, 0.1],
|
||||
[0.1, 0.9, 0.1],
|
||||
[0.1, 0.1, 0.9],
|
||||
],
|
||||
),
|
||||
ordering=models.WriteOrdering.STRONG,
|
||||
)
|
||||
```
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
PointStruct, UpsertPointsBuilder, WriteOrdering, WriteOrderingType,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
client
|
||||
.upsert_points(
|
||||
UpsertPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![
|
||||
PointStruct::new(1, vec![0.9, 0.1, 0.1], [("color", "red".into())]),
|
||||
PointStruct::new(2, vec![0.1, 0.9, 0.1], [("color", "green".into())]),
|
||||
PointStruct::new(3, vec![0.1, 0.1, 0.9], [("color", "blue".into())]),
|
||||
],
|
||||
)
|
||||
.ordering(WriteOrdering {
|
||||
r#type: WriteOrderingType::Strong.into(),
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
```typescript
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
client.upsert("{collection_name}", {
|
||||
batch: {
|
||||
ids: [1, 2, 3],
|
||||
payloads: [{ color: "red" }, { color: "green" }, { color: "blue" }],
|
||||
vectors: [
|
||||
[0.9, 0.1, 0.1],
|
||||
[0.1, 0.9, 0.1],
|
||||
[0.1, 0.1, 0.9],
|
||||
],
|
||||
},
|
||||
ordering: "strong",
|
||||
});
|
||||
```
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
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.Upsert(context.Background(), &qdrant.UpsertPoints{
|
||||
CollectionName: "{collection_name}",
|
||||
Points: []*qdrant.PointStruct{
|
||||
{
|
||||
Id: qdrant.NewIDNum(1),
|
||||
Vectors: qdrant.NewVectors(0.9, 0.1, 0.1),
|
||||
Payload: qdrant.NewValueMap(map[string]any{"color": "red"}),
|
||||
},
|
||||
{
|
||||
Id: qdrant.NewIDNum(2),
|
||||
Vectors: qdrant.NewVectors(0.1, 0.9, 0.1),
|
||||
Payload: qdrant.NewValueMap(map[string]any{"color": "green"}),
|
||||
},
|
||||
{
|
||||
Id: qdrant.NewIDNum(3),
|
||||
Vectors: qdrant.NewVectors(0.1, 0.1, 0.9),
|
||||
Payload: qdrant.NewValueMap(map[string]any{"color": "blue"}),
|
||||
},
|
||||
},
|
||||
Ordering: &qdrant.WriteOrdering{
|
||||
Type: qdrant.WriteOrderingType_Strong,
|
||||
},
|
||||
})
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
```http
|
||||
PUT /collections/{collection_name}/points?ordering=strong
|
||||
{
|
||||
"batch": {
|
||||
"ids": [1, 2, 3],
|
||||
"payloads": [
|
||||
{"color": "red"},
|
||||
{"color": "green"},
|
||||
{"color": "blue"}
|
||||
],
|
||||
"vectors": [
|
||||
[0.9, 0.1, 0.1],
|
||||
[0.1, 0.9, 0.1],
|
||||
[0.1, 0.1, 0.9]
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.example.snippets_amalgamation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.qdrant.client.PointIdFactory.id;
|
||||
import static io.qdrant.client.ValueFactory.value;
|
||||
import static io.qdrant.client.VectorsFactory.vectors;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Points.PointStruct;
|
||||
import io.qdrant.client.grpc.Points.UpsertPoints;
|
||||
import io.qdrant.client.grpc.Points.WriteOrdering;
|
||||
import io.qdrant.client.grpc.Points.WriteOrderingType;
|
||||
|
||||
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(
|
||||
UpsertPoints.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.addAllPoints(
|
||||
List.of(
|
||||
PointStruct.newBuilder()
|
||||
.setId(id(1))
|
||||
.setVectors(vectors(0.9f, 0.1f, 0.1f))
|
||||
.putAllPayload(Map.of("color", value("red")))
|
||||
.build(),
|
||||
PointStruct.newBuilder()
|
||||
.setId(id(2))
|
||||
.setVectors(vectors(0.1f, 0.9f, 0.1f))
|
||||
.putAllPayload(Map.of("color", value("green")))
|
||||
.build(),
|
||||
PointStruct.newBuilder()
|
||||
.setId(id(3))
|
||||
.setVectors(vectors(0.1f, 0.1f, 0.9f))
|
||||
.putAllPayload(Map.of("color", value("blue")))
|
||||
.build()))
|
||||
.setOrdering(WriteOrdering.newBuilder().setType(WriteOrderingType.Strong).build())
|
||||
.build())
|
||||
.get();
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
# @hide-start
|
||||
client = QdrantClient(url="http://localhost:6333")
|
||||
# @hide-end
|
||||
|
||||
client.upsert(
|
||||
collection_name="{collection_name}",
|
||||
points=models.Batch(
|
||||
ids=[1, 2, 3],
|
||||
payloads=[
|
||||
{"color": "red"},
|
||||
{"color": "green"},
|
||||
{"color": "blue"},
|
||||
],
|
||||
vectors=[
|
||||
[0.9, 0.1, 0.1],
|
||||
[0.1, 0.9, 0.1],
|
||||
[0.1, 0.1, 0.9],
|
||||
],
|
||||
),
|
||||
ordering=models.WriteOrdering.STRONG,
|
||||
)
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
use qdrant_client::qdrant::{
|
||||
PointStruct, UpsertPointsBuilder, WriteOrdering, WriteOrderingType,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
pub async fn main() -> anyhow::Result<()> {
|
||||
// @hide-start
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
// @hide-end
|
||||
|
||||
client
|
||||
.upsert_points(
|
||||
UpsertPointsBuilder::new(
|
||||
"{collection_name}",
|
||||
vec![
|
||||
PointStruct::new(1, vec![0.9, 0.1, 0.1], [("color", "red".into())]),
|
||||
PointStruct::new(2, vec![0.1, 0.9, 0.1], [("color", "green".into())]),
|
||||
PointStruct::new(3, vec![0.1, 0.1, 0.9], [("color", "blue".into())]),
|
||||
],
|
||||
)
|
||||
.ordering(WriteOrdering {
|
||||
r#type: WriteOrderingType::Strong.into(),
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
// @hide-start
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
// @hide-end
|
||||
|
||||
client.upsert("{collection_name}", {
|
||||
batch: {
|
||||
ids: [1, 2, 3],
|
||||
payloads: [{ color: "red" }, { color: "green" }, { color: "blue" }],
|
||||
vectors: [
|
||||
[0.9, 0.1, 0.1],
|
||||
[0.1, 0.9, 0.1],
|
||||
[0.1, 0.1, 0.9],
|
||||
],
|
||||
},
|
||||
ordering: "strong",
|
||||
});
|
||||
+1
@@ -0,0 +1 @@
|
||||
This code snippet runs a query with a read `consistency` of `majority`. Qdrant queries multiple replicas and returns only the points present on the majority of them, which helps avoid inconsistent results when replicas are concurrently updated.
|
||||
+22
@@ -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()
|
||||
{
|
||||
// @hide-start
|
||||
var client = new QdrantClient("localhost", 6334);
|
||||
// @hide-end
|
||||
|
||||
await client.QueryAsync(
|
||||
collectionName: "{collection_name}",
|
||||
query: new float[] { 0.2f, 0.1f, 0.9f, 0.7f },
|
||||
filter: MatchKeyword("city", "London"),
|
||||
searchParams: new SearchParams { HnswEf = 128, Exact = false },
|
||||
limit: 3,
|
||||
readConsistency: new ReadConsistency { Type = ReadConsistencyType.Majority }
|
||||
);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
```csharp
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
using static Qdrant.Client.Grpc.Conditions;
|
||||
|
||||
await client.QueryAsync(
|
||||
collectionName: "{collection_name}",
|
||||
query: new float[] { 0.2f, 0.1f, 0.9f, 0.7f },
|
||||
filter: MatchKeyword("city", "London"),
|
||||
searchParams: new SearchParams { HnswEf = 128, Exact = false },
|
||||
limit: 3,
|
||||
readConsistency: new ReadConsistency { Type = ReadConsistencyType.Majority }
|
||||
);
|
||||
```
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
```go
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/qdrant/go-client/qdrant"
|
||||
)
|
||||
|
||||
client.Query(context.Background(), &qdrant.QueryPoints{
|
||||
CollectionName: "{collection_name}",
|
||||
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
|
||||
Filter: &qdrant.Filter{
|
||||
Must: []*qdrant.Condition{
|
||||
qdrant.NewMatch("city", "London"),
|
||||
},
|
||||
},
|
||||
Params: &qdrant.SearchParams{
|
||||
HnswEf: qdrant.PtrOf(uint64(128)),
|
||||
},
|
||||
Limit: qdrant.PtrOf(uint64(3)),
|
||||
ReadConsistency: qdrant.NewReadConsistencyType(qdrant.ReadConsistencyType_Majority),
|
||||
})
|
||||
```
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
```java
|
||||
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.ReadConsistency;
|
||||
import io.qdrant.client.grpc.Points.ReadConsistencyType;
|
||||
import io.qdrant.client.grpc.Points.SearchParams;
|
||||
|
||||
import static io.qdrant.client.QueryFactory.nearest;
|
||||
import static io.qdrant.client.ConditionFactory.matchKeyword;
|
||||
|
||||
client.queryAsync(
|
||||
QueryPoints.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.setFilter(Filter.newBuilder().addMust(matchKeyword("city", "London")).build())
|
||||
.setQuery(nearest(.2f, 0.1f, 0.9f, 0.7f))
|
||||
.setParams(SearchParams.newBuilder().setHnswEf(128).setExact(false).build())
|
||||
.setLimit(3)
|
||||
.setReadConsistency(
|
||||
ReadConsistency.newBuilder().setType(ReadConsistencyType.Majority).build())
|
||||
.build())
|
||||
.get();
|
||||
```
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
```python
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
client.query_points(
|
||||
collection_name="{collection_name}",
|
||||
query=[0.2, 0.1, 0.9, 0.7],
|
||||
query_filter=models.Filter(
|
||||
must=[
|
||||
models.FieldCondition(
|
||||
key="city",
|
||||
match=models.MatchValue(
|
||||
value="London",
|
||||
),
|
||||
)
|
||||
]
|
||||
),
|
||||
search_params=models.SearchParams(hnsw_ef=128, exact=False),
|
||||
limit=3,
|
||||
consistency="majority",
|
||||
)
|
||||
```
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
```rust
|
||||
use qdrant_client::qdrant::{
|
||||
read_consistency::Value, Condition, Filter, QueryPointsBuilder, ReadConsistencyType,
|
||||
SearchParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
client
|
||||
.query(
|
||||
QueryPointsBuilder::new("{collection_name}")
|
||||
.query(vec![0.2, 0.1, 0.9, 0.7])
|
||||
.limit(3)
|
||||
.filter(Filter::must([Condition::matches(
|
||||
"city",
|
||||
"London".to_string(),
|
||||
)]))
|
||||
.params(SearchParamsBuilder::default().hnsw_ef(128).exact(false))
|
||||
.read_consistency(Value::Type(ReadConsistencyType::Majority.into())),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
```typescript
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
filter: {
|
||||
must: [{ key: "city", match: { value: "London" } }],
|
||||
},
|
||||
params: {
|
||||
hnsw_ef: 128,
|
||||
exact: false,
|
||||
},
|
||||
limit: 3,
|
||||
consistency: "majority",
|
||||
});
|
||||
```
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
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.2, 0.1, 0.9, 0.7),
|
||||
Filter: &qdrant.Filter{
|
||||
Must: []*qdrant.Condition{
|
||||
qdrant.NewMatch("city", "London"),
|
||||
},
|
||||
},
|
||||
Params: &qdrant.SearchParams{
|
||||
HnswEf: qdrant.PtrOf(uint64(128)),
|
||||
},
|
||||
Limit: qdrant.PtrOf(uint64(3)),
|
||||
ReadConsistency: qdrant.NewReadConsistencyType(qdrant.ReadConsistencyType_Majority),
|
||||
})
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
```http
|
||||
POST /collections/{collection_name}/points/query?consistency=majority
|
||||
{
|
||||
"query": [0.2, 0.1, 0.9, 0.7],
|
||||
"filter": {
|
||||
"must": [
|
||||
{
|
||||
"key": "city",
|
||||
"match": {
|
||||
"value": "London"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"hnsw_ef": 128,
|
||||
"exact": false
|
||||
},
|
||||
"limit": 3
|
||||
}
|
||||
```
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.example.snippets_amalgamation;
|
||||
|
||||
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.ReadConsistency;
|
||||
import io.qdrant.client.grpc.Points.ReadConsistencyType;
|
||||
import io.qdrant.client.grpc.Points.SearchParams;
|
||||
|
||||
import static io.qdrant.client.QueryFactory.nearest;
|
||||
import static io.qdrant.client.ConditionFactory.matchKeyword;
|
||||
|
||||
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("city", "London")).build())
|
||||
.setQuery(nearest(.2f, 0.1f, 0.9f, 0.7f))
|
||||
.setParams(SearchParams.newBuilder().setHnswEf(128).setExact(false).build())
|
||||
.setLimit(3)
|
||||
.setReadConsistency(
|
||||
ReadConsistency.newBuilder().setType(ReadConsistencyType.Majority).build())
|
||||
.build())
|
||||
.get();
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
# @hide-start
|
||||
# mypy: disable-error-code="arg-type"
|
||||
# @hide-end
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
# @hide-start
|
||||
client = QdrantClient(url="http://localhost:6333")
|
||||
# @hide-end
|
||||
|
||||
client.query_points(
|
||||
collection_name="{collection_name}",
|
||||
query=[0.2, 0.1, 0.9, 0.7],
|
||||
query_filter=models.Filter(
|
||||
must=[
|
||||
models.FieldCondition(
|
||||
key="city",
|
||||
match=models.MatchValue(
|
||||
value="London",
|
||||
),
|
||||
)
|
||||
]
|
||||
),
|
||||
search_params=models.SearchParams(hnsw_ef=128, exact=False),
|
||||
limit=3,
|
||||
consistency="majority",
|
||||
)
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
use qdrant_client::qdrant::{
|
||||
read_consistency::Value, Condition, Filter, QueryPointsBuilder, ReadConsistencyType,
|
||||
SearchParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
pub async fn main() -> anyhow::Result<()> {
|
||||
// @hide-start
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
// @hide-end
|
||||
|
||||
client
|
||||
.query(
|
||||
QueryPointsBuilder::new("{collection_name}")
|
||||
.query(vec![0.2, 0.1, 0.9, 0.7])
|
||||
.limit(3)
|
||||
.filter(Filter::must([Condition::matches(
|
||||
"city",
|
||||
"London".to_string(),
|
||||
)]))
|
||||
.params(SearchParamsBuilder::default().hnsw_ef(128).exact(false))
|
||||
.read_consistency(Value::Type(ReadConsistencyType::Majority.into())),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
// @hide-start
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
// @hide-end
|
||||
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
filter: {
|
||||
must: [{ key: "city", match: { value: "London" } }],
|
||||
},
|
||||
params: {
|
||||
hnsw_ef: 128,
|
||||
exact: false,
|
||||
},
|
||||
limit: 3,
|
||||
consistency: "majority",
|
||||
});
|
||||
Reference in New Issue
Block a user