mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-08 04:18:32 +02:00
Shortcode for rendering code snippets from separate markdown files (#1548)
* shortcode for rendering code snippets from separate markdown files * formatted code * fix and readme * semi-automatically extracts snippets from markdown * extract snippets from points.md * extract snippets from vectors.md * extract snippets from payload.md * extract snippets from search.md + fixes * extract snippets from explore.md * extract snippets from hybrid-queries.md + mode query by id into search * extract snippets from filtering.md * extract snippets from storage.md + update outdated info * extract snippets from indexing.md * extract snippets from snapshots.md * extract snippets from guides/optimize.md * extract snippets from guides/multiple-partitions.md + fix aside note * extract snippets from guides/quantization.md * use auto-generated descriptions * order json snippets first --------- Co-authored-by: generall <andrey@vasnetsov.com>
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
This code snippet is for a PUT request to insert points into a collection, where each point has an ID, a payload containing a group ID, and a vector. The code illustrates partitioning vectors by user to ensure that each user can only access their own vectors. It emphasizes adding a `group_id` field to each vector in the collection, facilitating user-specific data access control. Additionally, it suggests using an appropriate naming convention for the key in the payload for flexibility in data structures.
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
```csharp
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
var client = new QdrantClient("localhost", 6334);
|
||||
|
||||
await client.UpsertAsync(
|
||||
collectionName: "{collection_name}",
|
||||
points: new List<PointStruct>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Id = 1,
|
||||
Vectors = new[] { 0.9f, 0.1f, 0.1f },
|
||||
Payload = { ["group_id"] = "user_1" }
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 2,
|
||||
Vectors = new[] { 0.1f, 0.9f, 0.1f },
|
||||
Payload = { ["group_id"] = "user_1" }
|
||||
},
|
||||
new()
|
||||
{
|
||||
Id = 3,
|
||||
Vectors = new[] { 0.1f, 0.1f, 0.9f },
|
||||
Payload = { ["group_id"] = "user_2" }
|
||||
}
|
||||
}
|
||||
);
|
||||
```
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
```go
|
||||
import (
|
||||
"context"
|
||||
|
||||
"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{
|
||||
{
|
||||
Id: qdrant.NewIDNum(1),
|
||||
Vectors: qdrant.NewVectors(0.9, 0.1, 0.1),
|
||||
Payload: qdrant.NewValueMap(map[string]any{"group_id": "user_1"}),
|
||||
},
|
||||
{
|
||||
Id: qdrant.NewIDNum(2),
|
||||
Vectors: qdrant.NewVectors(0.1, 0.9, 0.1),
|
||||
Payload: qdrant.NewValueMap(map[string]any{"group_id": "user_1"}),
|
||||
},
|
||||
{
|
||||
Id: qdrant.NewIDNum(3),
|
||||
Vectors: qdrant.NewVectors(0.1, 0.1, 0.9),
|
||||
Payload: qdrant.NewValueMap(map[string]any{"group_id": "user_2"}),
|
||||
},
|
||||
},
|
||||
})
|
||||
```
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
```http
|
||||
PUT /collections/{collection_name}/points
|
||||
{
|
||||
"points": [
|
||||
{
|
||||
"id": 1,
|
||||
"payload": {"group_id": "user_1"},
|
||||
"vector": [0.9, 0.1, 0.1]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"payload": {"group_id": "user_1"},
|
||||
"vector": [0.1, 0.9, 0.1]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"payload": {"group_id": "user_2"},
|
||||
"vector": [0.1, 0.1, 0.9]
|
||||
},
|
||||
]
|
||||
}
|
||||
```
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
```java
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Points.PointStruct;
|
||||
|
||||
QdrantClient client =
|
||||
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
|
||||
|
||||
client
|
||||
.upsertAsync(
|
||||
"{collection_name}",
|
||||
List.of(
|
||||
PointStruct.newBuilder()
|
||||
.setId(id(1))
|
||||
.setVectors(vectors(0.9f, 0.1f, 0.1f))
|
||||
.putAllPayload(Map.of("group_id", value("user_1")))
|
||||
.build(),
|
||||
PointStruct.newBuilder()
|
||||
.setId(id(2))
|
||||
.setVectors(vectors(0.1f, 0.9f, 0.1f))
|
||||
.putAllPayload(Map.of("group_id", value("user_1")))
|
||||
.build(),
|
||||
PointStruct.newBuilder()
|
||||
.setId(id(3))
|
||||
.setVectors(vectors(0.1f, 0.1f, 0.9f))
|
||||
.putAllPayload(Map.of("group_id", value("user_2")))
|
||||
.build()))
|
||||
.get();
|
||||
```
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
```python
|
||||
client.upsert(
|
||||
collection_name="{collection_name}",
|
||||
points=[
|
||||
models.PointStruct(
|
||||
id=1,
|
||||
payload={"group_id": "user_1"},
|
||||
vector=[0.9, 0.1, 0.1],
|
||||
),
|
||||
models.PointStruct(
|
||||
id=2,
|
||||
payload={"group_id": "user_1"},
|
||||
vector=[0.1, 0.9, 0.1],
|
||||
),
|
||||
models.PointStruct(
|
||||
id=3,
|
||||
payload={"group_id": "user_2"},
|
||||
vector=[0.1, 0.1, 0.9],
|
||||
),
|
||||
],
|
||||
)
|
||||
```
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
```rust
|
||||
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}",
|
||||
vec![
|
||||
PointStruct::new(1, vec![0.9, 0.1, 0.1], [("group_id", "user_1".into())]),
|
||||
PointStruct::new(2, vec![0.1, 0.9, 0.1], [("group_id", "user_1".into())]),
|
||||
PointStruct::new(3, vec![0.1, 0.1, 0.9], [("group_id", "user_2".into())]),
|
||||
],
|
||||
))
|
||||
.await?;
|
||||
```
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
```typescript
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.upsert("{collection_name}", {
|
||||
points: [
|
||||
{
|
||||
id: 1,
|
||||
payload: { group_id: "user_1" },
|
||||
vector: [0.9, 0.1, 0.1],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
payload: { group_id: "user_1" },
|
||||
vector: [0.1, 0.9, 0.1],
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
payload: { group_id: "user_2" },
|
||||
vector: [0.1, 0.1, 0.9],
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
Reference in New Issue
Block a user