mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-09 12:58:31 +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:
@@ -0,0 +1,21 @@
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
public class Snippet
|
||||
{
|
||||
public static async Task Run()
|
||||
{
|
||||
var client = new QdrantClient(
|
||||
host: "xyz-example.qdrant.io",
|
||||
port: 6334,
|
||||
https: true,
|
||||
apiKey: "<your-api-key>"
|
||||
);
|
||||
|
||||
await client.QueryAsync(
|
||||
collectionName: "{collection_name}",
|
||||
query: new Document() { Model = "qdrant/bm25", Text = "How to bake cookies?" },
|
||||
usingVector: "my-bm25-vector"
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -23,4 +23,4 @@ client.Query(ctx, &qdrant.QueryPoints{
|
||||
),
|
||||
Using: qdrant.PtrOf("my-bm25-vector"),
|
||||
})
|
||||
```
|
||||
```
|
||||
+2
-2
@@ -3,8 +3,8 @@ import static io.qdrant.client.QueryFactory.nearest;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Points;
|
||||
import io.qdrant.client.grpc.Points.Document;
|
||||
import io.qdrant.client.grpc.Points;
|
||||
|
||||
QdrantClient client =
|
||||
new QdrantClient(
|
||||
@@ -24,4 +24,4 @@ client
|
||||
.setUsing("my-bm25-vector")
|
||||
.build())
|
||||
.get();
|
||||
```
|
||||
```
|
||||
+1
-1
@@ -15,4 +15,4 @@ client.query_points(
|
||||
),
|
||||
using="my-bm25-vector",
|
||||
)
|
||||
```
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
package snippet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/qdrant/go-client/qdrant"
|
||||
)
|
||||
|
||||
func Main() {
|
||||
client, err := qdrant.NewClient(&qdrant.Config{
|
||||
Host: "xyz-example.qdrant.io",
|
||||
Port: 6334,
|
||||
APIKey: "<paste-your-api-key-here>",
|
||||
UseTLS: true,
|
||||
})
|
||||
|
||||
client.Query(ctx, &qdrant.QueryPoints{
|
||||
CollectionName: "{collection_name}",
|
||||
Query: qdrant.NewQueryNearest(
|
||||
qdrant.NewVectorInputDocument(&qdrant.Document{
|
||||
Model: "qdrant/bm25",
|
||||
Text: "How to bake cookies?",
|
||||
}),
|
||||
),
|
||||
Using: qdrant.PtrOf("my-bm25-vector"),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.example.snippets_amalgamation;
|
||||
|
||||
import static io.qdrant.client.QueryFactory.nearest;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Points.Document;
|
||||
import io.qdrant.client.grpc.Points;
|
||||
|
||||
public class Snippet {
|
||||
public static void run() throws Exception {
|
||||
QdrantClient client =
|
||||
new QdrantClient(
|
||||
QdrantGrpcClient.newBuilder("xyz-example.qdrant.io", 6334, true)
|
||||
.withApiKey("<your-api-key")
|
||||
.build());
|
||||
client
|
||||
.queryAsync(
|
||||
Points.QueryPoints.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.setQuery(
|
||||
nearest(
|
||||
Document.newBuilder()
|
||||
.setModel("qdrant/bm25")
|
||||
.setText("How to bake cookies?")
|
||||
.build()))
|
||||
.setUsing("my-bm25-vector")
|
||||
.build())
|
||||
.get();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
client = QdrantClient(
|
||||
url="https://xyz-example.qdrant.io:6333",
|
||||
api_key="<your-api-key>",
|
||||
cloud_inference=True
|
||||
)
|
||||
|
||||
client.query_points(
|
||||
collection_name="{collection_name}",
|
||||
query=models.Document(
|
||||
text="How to bake cookies?",
|
||||
model="Qdrant/bm25",
|
||||
),
|
||||
using="my-bm25-vector",
|
||||
)
|
||||
@@ -0,0 +1,23 @@
|
||||
use qdrant_client::{
|
||||
Qdrant, QdrantError,
|
||||
qdrant::{Document, Query, QueryPointsBuilder},
|
||||
};
|
||||
|
||||
pub async fn main() -> anyhow::Result<()> {
|
||||
let client = Qdrant::from_url("<your-qdrant-url>").build().unwrap();
|
||||
|
||||
client
|
||||
.query(
|
||||
QueryPointsBuilder::new("{collection_name}")
|
||||
.query(Query::new_nearest(Document {
|
||||
text: "How to bake cookies?".into(),
|
||||
model: "qdrant/bm25".into(),
|
||||
..Default::default()
|
||||
}))
|
||||
.using("my-bm25-vector")
|
||||
.build(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { QdrantClient } from "@qdrant/js-client-rest";
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 });
|
||||
|
||||
client.query("{collection_name}", {
|
||||
query: {
|
||||
text: 'How to bake cookies?',
|
||||
model: 'qdrant/bm25',
|
||||
},
|
||||
using: 'my-bm25-vector',
|
||||
});
|
||||
Reference in New Issue
Block a user