mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-10 21:38:30 +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:
+25
@@ -0,0 +1,25 @@
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
|
||||
public class Snippet
|
||||
{
|
||||
public static async Task Run()
|
||||
{
|
||||
var client = new QdrantClient("localhost", 6334);
|
||||
|
||||
await client.QueryAsync(
|
||||
collectionName: "{collection_name}",
|
||||
query: new RecommendInput {
|
||||
Positive = { 100, 231 },
|
||||
Negative = { 718 }
|
||||
},
|
||||
usingVector: "image",
|
||||
limit: 10,
|
||||
lookupFrom: new LookupLocation
|
||||
{
|
||||
CollectionName = "{external_collection_name}",
|
||||
VectorName = "{external_vector_name}",
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -1,12 +1,11 @@
|
||||
```java
|
||||
import java.util.List;
|
||||
import static io.qdrant.client.QueryFactory.recommend;
|
||||
import static io.qdrant.client.VectorInputFactory.vectorInput;
|
||||
|
||||
import io.qdrant.client.grpc.Points.LookupLocation;
|
||||
import io.qdrant.client.grpc.Points.QueryPoints;
|
||||
import io.qdrant.client.grpc.Points.RecommendInput;
|
||||
|
||||
import static io.qdrant.client.VectorInputFactory.vectorInput;
|
||||
import static io.qdrant.client.QueryFactory.recommend;
|
||||
import java.util.List;
|
||||
|
||||
client.queryAsync(QueryPoints.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package snippet
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/qdrant/go-client/qdrant"
|
||||
)
|
||||
|
||||
func Main() {
|
||||
client, err := qdrant.NewClient(&qdrant.Config{
|
||||
Host: "localhost",
|
||||
Port: 6334,
|
||||
})
|
||||
|
||||
client.Query(context.Background(), &qdrant.QueryPoints{
|
||||
CollectionName: "{collection_name}",
|
||||
Query: qdrant.NewQueryRecommend(&qdrant.RecommendInput{
|
||||
Positive: []*qdrant.VectorInput{
|
||||
qdrant.NewVectorInputID(qdrant.NewIDNum(100)),
|
||||
qdrant.NewVectorInputID(qdrant.NewIDNum(231)),
|
||||
},
|
||||
Negative: []*qdrant.VectorInput{
|
||||
qdrant.NewVectorInputID(qdrant.NewIDNum(718)),
|
||||
},
|
||||
}),
|
||||
Using: qdrant.PtrOf("image"),
|
||||
LookupFrom: &qdrant.LookupLocation{
|
||||
CollectionName: "{external_collection_name}",
|
||||
VectorName: qdrant.PtrOf("{external_vector_name}"),
|
||||
},
|
||||
})
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.example.snippets_amalgamation;
|
||||
|
||||
import static io.qdrant.client.QueryFactory.recommend;
|
||||
import static io.qdrant.client.VectorInputFactory.vectorInput;
|
||||
|
||||
import io.qdrant.client.grpc.Points.LookupLocation;
|
||||
import io.qdrant.client.grpc.Points.QueryPoints;
|
||||
import io.qdrant.client.grpc.Points.RecommendInput;
|
||||
import java.util.List;
|
||||
|
||||
public class Snippet {
|
||||
public static void run() throws Exception {
|
||||
client.queryAsync(QueryPoints.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.setQuery(recommend(RecommendInput.newBuilder()
|
||||
.addAllPositive(List.of(vectorInput(100), vectorInput(231)))
|
||||
.addAllNegative(List.of(vectorInput(718)))
|
||||
.build()))
|
||||
.setUsing("image")
|
||||
.setLimit(10)
|
||||
.setLookupFrom(
|
||||
LookupLocation.newBuilder()
|
||||
.setCollectionName("{external_collection_name}")
|
||||
.setVectorName("{external_vector_name}")
|
||||
.build())
|
||||
.build()).get();
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
from qdrant_client import QdrantClient, models # @hide
|
||||
|
||||
client = QdrantClient(url="http://localhost:6333") # @hide
|
||||
|
||||
client.query_points(
|
||||
collection_name="{collection_name}",
|
||||
query=models.RecommendQuery(
|
||||
recommend=models.RecommendInput(
|
||||
positive=[100, 231],
|
||||
negative=[718],
|
||||
)
|
||||
),
|
||||
using="image",
|
||||
limit=10,
|
||||
lookup_from=models.LookupLocation(
|
||||
collection="{external_collection_name}", vector="{external_vector_name}"
|
||||
),
|
||||
)
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
use qdrant_client::qdrant::{LookupLocationBuilder, QueryPointsBuilder, RecommendInputBuilder};
|
||||
|
||||
pub async fn main() -> anyhow::Result<()> {
|
||||
client
|
||||
.query(
|
||||
QueryPointsBuilder::new("{collection_name}")
|
||||
.query(
|
||||
RecommendInputBuilder::default()
|
||||
.add_positive(100)
|
||||
.add_positive(231)
|
||||
.add_negative(718)
|
||||
.build(),
|
||||
)
|
||||
.limit(10)
|
||||
.using("image")
|
||||
.lookup_from(
|
||||
LookupLocationBuilder::new("{external_collection_name}")
|
||||
.vector_name("{external_vector_name}"),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
|
||||
|
||||
client.query("{collection_name}", {
|
||||
query: {
|
||||
recommend: {
|
||||
positive: [100, 231],
|
||||
negative: [718],
|
||||
}
|
||||
},
|
||||
using: "image",
|
||||
limit: 10,
|
||||
lookup_from: {
|
||||
collection: "{external_collection_name}",
|
||||
vector: "{external_vector_name}"
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user