mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-10 05:18:32 +02:00
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:
+17
@@ -0,0 +1,17 @@
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
public class Snippet
|
||||
{
|
||||
public static async Task Run()
|
||||
{
|
||||
var client = new QdrantClient("localhost", 6334);
|
||||
|
||||
await client.CreateCollectionAsync(
|
||||
collectionName: "{collection_name}",
|
||||
// ... other collection parameters
|
||||
shardNumber: 1,
|
||||
shardingMethod: ShardingMethod.Custom
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -9,4 +9,4 @@ client.create_collection(
|
||||
sharding_method=models.ShardingMethod.CUSTOM,
|
||||
# ... other collection parameters
|
||||
)
|
||||
```
|
||||
```
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package snippet
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/qdrant/go-client/qdrant"
|
||||
)
|
||||
|
||||
func Main() {
|
||||
client, err := qdrant.NewClient(&qdrant.Config{
|
||||
Host: "localhost",
|
||||
Port: 6334,
|
||||
})
|
||||
|
||||
client.CreateCollection(context.Background(), &qdrant.CreateCollection{
|
||||
CollectionName: "{collection_name}",
|
||||
// ... other collection parameters
|
||||
ShardNumber: qdrant.PtrOf(uint32(1)),
|
||||
ShardingMethod: qdrant.ShardingMethod_Custom.Enum(),
|
||||
})
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.example.snippets_amalgamation;
|
||||
|
||||
import static io.qdrant.client.ShardKeyFactory.shardKey;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Collections.CreateCollection;
|
||||
import io.qdrant.client.grpc.Collections.ShardingMethod;
|
||||
|
||||
public class Snippet {
|
||||
public static void run() throws Exception {
|
||||
QdrantClient client =
|
||||
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
|
||||
|
||||
client
|
||||
.createCollectionAsync(
|
||||
CreateCollection.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
// ... other collection parameters
|
||||
.setShardNumber(1)
|
||||
.setShardingMethod(ShardingMethod.Custom)
|
||||
.build())
|
||||
.get();
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
client = QdrantClient(url="http://localhost:6333")
|
||||
|
||||
client.create_collection(
|
||||
collection_name="{collection_name}",
|
||||
shard_number=1,
|
||||
sharding_method=models.ShardingMethod.CUSTOM,
|
||||
# ... other collection parameters
|
||||
)
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
use qdrant_client::qdrant::{
|
||||
CreateCollectionBuilder, Distance, ShardingMethod, VectorParamsBuilder,
|
||||
};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
pub async fn main() -> anyhow::Result<()> {
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?;
|
||||
|
||||
client
|
||||
.create_collection(
|
||||
CreateCollectionBuilder::new("{collection_name}")
|
||||
.vectors_config(VectorParamsBuilder::new(300, Distance::Cosine))
|
||||
.shard_number(1)
|
||||
.sharding_method(ShardingMethod::Custom.into()),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.createCollection("{collection_name}", {
|
||||
shard_number: 1,
|
||||
sharding_method: "custom",
|
||||
// ... other collection parameters
|
||||
});
|
||||
Reference in New Issue
Block a user