Automated snippet conversion by scripts

These changes are purely mechanical to differentiate them from manual
fixes/adjustments made in the next commit.
This results in broken code as some snippets contain errors.

Made in four steps:
1. Run ./migrate-snippet.py that converts `.md` files to code files
   and perhaps adds missing lines under `// @hide` comments.
2. Sort Java imports.
3. Remove old `.md` files.
4. Run ./generate.md to produce `*/generated/*.md` files.
This commit is contained in:
xzfc
2025-11-28 22:00:47 +00:00
parent cdfbd6538a
commit 00896acb28
2300 changed files with 22902 additions and 378 deletions
@@ -0,0 +1,14 @@
```bash
curl -X PUT http://localhost:6333/collections/{collection_name} \
-H 'Content-Type: application/json' \
--data-raw '{
"vectors": {
"size": 300,
"distance": "Cosine"
},
"metadata": {
"my-metadata-field": "value-1",
"another-field": 123
}
}'
```
@@ -0,0 +1,16 @@
```csharp
using Qdrant.Client;
using Qdrant.Client.Grpc;
var client = new QdrantClient("localhost", 6334);
await client.CreateCollectionAsync(
collectionName: "{collection_name}",
vectorsConfig: new VectorParams { Size = 100, Distance = Distance.Cosine },
metadata: new()
{
["my-metadata-field"] = "value-1",
["another-field"] = 123
}
);
```
@@ -0,0 +1,24 @@
```go
import (
"context"
"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{
Size: 100,
Distance: qdrant.Distance_Cosine,
}),
Metadata: qdrant.NewValueMap(map[string]any{
"my-metadata-field": "value-1",
"another-field": 123,
}),
})
```
@@ -0,0 +1,33 @@
```java
import static io.qdrant.client.ValueFactory.value;
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;
import java.util.Map;
QdrantClient client = new QdrantClient(
QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
client
.createCollectionAsync(
CreateCollection.newBuilder()
.setCollectionName("{collection_name}")
.setVectorsConfig(
VectorsConfig.newBuilder()
.setParams(
VectorParams.newBuilder()
.setDistance(Distance.Cosine)
.setSize(100)
.build())
.build())
.putAllMetadata(
Map.of(
"my-metadata-field", value("value-1"),
"another-field", value(123)))
.build())
.get();
```
@@ -0,0 +1,13 @@
```python
from qdrant_client import QdrantClient, models
client = QdrantClient(url="http://localhost:6333")
client.create_collection(
collection_name="{collection_name}",
metadata={
"my-metadata-field": "value-1",
"another-field": 123
},
)
```
@@ -0,0 +1,20 @@
```rust
use qdrant_client::qdrant::{CreateCollectionBuilder, Distance, VectorParamsBuilder};
use qdrant_client::Qdrant;
use serde_json::{json, Value};
use std::collections::HashMap;
let client = Qdrant::from_url("http://localhost:6334").build()?;
let mut metadata: HashMap<String, Value> = HashMap::new();
metadata.insert("my-metadata-field".to_string(), json!("value-1"));
metadata.insert("another-field".to_string(), json!(123));
client
.create_collection(
CreateCollectionBuilder::new("{collection_name}")
.vectors_config(VectorParamsBuilder::new(100, Distance::Cosine))
.metadata(metadata),
)
.await?;
```
@@ -0,0 +1,13 @@
```typescript
import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
client.createCollection("{collection_name}", {
vectors: { size: 100, distance: "Cosine" },
metadata: {
"my-metadata-field": "value-1",
"another-field": 123
}
});
```