Fix type-checking errors in snippets (code only, no .md)

This commit both:
- Fixes pre-existing mistakes in snippets, aka wrong code samples.
- Adds hidden (`@hide`) statements that do not appear in the docs,
  but satisfy typecheckers.
This commit is contained in:
xzfc
2025-11-28 22:02:07 +00:00
parent 00896acb28
commit 74a785218b
410 changed files with 1161 additions and 252 deletions
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
@@ -1,7 +1,8 @@
use qdrant_client::qdrant::{Condition, Filter, QueryPointsBuilder, SearchParamsBuilder};
use qdrant_client::Qdrant;
pub async fn main() -> anyhow::Result<()> {
let client = qdrant_client::Qdrant::from_url("http://localhost:6334").build()?; // @hide
client
.query(
QueryPointsBuilder::new("{collection_name}")
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
filter := qdrant.Filter{
Must: []*qdrant.Condition{
qdrant.NewMatch("city", "London"),
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQueryID(qdrant.NewID("43cf51e2-8777-4f52-bc74-c2cbde0c8b04")),
@@ -1,5 +1,5 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{LookupLocationBuilder, PointId, Query, QueryPointsBuilder};
use qdrant_client::qdrant::{LookupLocationBuilder, Query, QueryPointsBuilder};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQueryID(qdrant.NewID("43cf51e2-8777-4f52-bc74-c2cbde0c8b04")),
@@ -1,5 +1,5 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{Condition, Filter, PointId, Query, QueryPointsBuilder};
use qdrant_client::qdrant::{PointId, Query, QueryPointsBuilder};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
@@ -7,7 +7,7 @@ pub async fn main() -> anyhow::Result<()> {
client
.query(
QueryPointsBuilder::new("{collection_name}")
.query(Query::new_nearest(PointId::new("43cf51e2-8777-4f52-bc74-c2cbde0c8b04")))
.query(Query::new_nearest(PointId::from("43cf51e2-8777-4f52-bc74-c2cbde0c8b04")))
)
.await?;
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQueryMMR(
@@ -1,5 +1,5 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{PrefetchQueryBuilder, Query, QueryPointsBuilder};
use qdrant_client::qdrant::{MmrBuilder, Query, QueryPointsBuilder};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
@@ -4,7 +4,7 @@ const client = new QdrantClient({ host: "localhost", port: 6333 });
client.query("{collection_name}", {
query: {
nearest: [0.01, 0.45, 0.67, ...], // search vector
nearest: [0.01, 0.45, 0.67], // search vector
mmr: {
diversity: 0.5, // 0.0 - relevance; 1.0 - diversity
candidates_limit: 100 // num of candidates to preselect
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Prefetch: []*qdrant.PrefetchQuery{
@@ -1,3 +1,4 @@
# mypy: disable-error-code="arg-type"
from qdrant_client import QdrantClient, models
client = QdrantClient(url="http://localhost:6333")
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Prefetch: []*qdrant.PrefetchQuery{
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Prefetch: []*qdrant.PrefetchQuery{
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Prefetch: []*qdrant.PrefetchQuery{
@@ -1,3 +1,4 @@
# type: ignore # error: Argument "query" to "Prefetch" has incompatible type "list[int]"; expected "list[float] | SparseVector | list[list[float]] | int | str | <13 more items> | None" [arg-type] # @hide
from qdrant_client import QdrantClient, models
client = QdrantClient(url="http://localhost:6333")
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Prefetch: []*qdrant.PrefetchQuery{
@@ -1,5 +1,5 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{Rrf, PrefetchQueryBuilder, Query, QueryPointsBuilder};
use qdrant_client::qdrant::{RrfBuilder, Query, QueryPointsBuilder};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
@@ -8,7 +8,7 @@ pub async fn main() -> anyhow::Result<()> {
QueryPointsBuilder::new("{collection_name}")
// .add_prefetch(...) <┐
// .add_prefetch(...) <┴─ 2+ prefetches here
.query(Query::new_rrf(RrfBuilder::with_k(60))
.query(Query::new_rrf(RrfBuilder::with_k(60)))
).await?;
Ok(())
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Prefetch: []*qdrant.PrefetchQuery{
@@ -10,7 +10,7 @@ public class Snippet
collectionName: "{collection_name}",
query: new float[][] {
[-0.013f, 0.020f, -0.007f, -0.111f],
[-0.030f, -0.055f, 0.001 , 0.072f],
[-0.030f, -0.055f, 0.001f, 0.072f],
[-0.041f, 0.014f, -0.032f, -0.062f],
}
);
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQueryMulti(
@@ -15,5 +15,6 @@ pub async fn main() -> anyhow::Result<()> {
))
).await?;
_ = res; // @hide
Ok(())
}
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.QueryGroups(context.Background(), &qdrant.QueryPointGroups{
CollectionName: "{collection_name}",
Query: qdrant.NewQuerySample(qdrant.Sample_Random),
@@ -1,5 +1,6 @@
from qdrant_client import QdrantClient, models
client = QdrantClient(url="http://localhost:6333")
sampled = client.query_points(
collection_name="{collection_name}",
@@ -1,5 +1,5 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{Query, QueryPointsBuilder};
use qdrant_client::qdrant::{Query, QueryPointsBuilder, Sample};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
@@ -11,5 +11,6 @@ pub async fn main() -> anyhow::Result<()> {
)
.await?;
_ = sampled; // @hide
Ok(())
}
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Prefetch: []*qdrant.PrefetchQuery{
@@ -18,6 +18,7 @@ import io.qdrant.client.grpc.Points.GeoDistance;
import io.qdrant.client.grpc.Points.PrefetchQuery;
import io.qdrant.client.grpc.Points.QueryPoints;
import io.qdrant.client.grpc.Points.SumExpression;
import java.util.Map;
public class Snippet {
public static void run() throws Exception {
@@ -1,12 +1,11 @@
client = QdrantClient(url="http://localhost:6333") # @hide
from qdrant_client import QdrantClient, models
client = QdrantClient(url="http://localhost:6333") # @hide
geo_boosted = client.query_points(
collection_name="{collection_name}",
prefetch=models.Prefetch(
query=[0.2, 0.8, ...], # <-- dense vector
query=[0.1, 0.45, 0.67], # <-- dense vector
limit=50
),
query=models.FormulaQuery(
@@ -2,9 +2,9 @@ import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
const distance_boosted = await client.query(collectionName, {
const distance_boosted = await client.query("{collection_name}", {
prefetch: {
query: [0.2, 0.8, ...],
query: [0.1, 0.45, 0.67],
limit: 50
},
query: {
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Prefetch: []*qdrant.PrefetchQuery{
@@ -1,12 +1,11 @@
client = QdrantClient(url="http://localhost:6333") # @hide
from qdrant_client import QdrantClient, models
client = QdrantClient(url="http://localhost:6333") # @hide
tag_boosted = client.query_points(
collection_name="{collection_name}",
prefetch=models.Prefetch(
query=[0.2, 0.8, ...], # <-- dense vector
query=[0.1, 0.45, 0.67], # <-- dense vector
limit=50
),
query=models.FormulaQuery(
@@ -2,7 +2,7 @@ import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
const tag_boosted = await client.query(collectionName, {
const tag_boosted = await client.query("{collection_name}", {
prefetch: {
query: [0.2, 0.8, 0.1, 0.9],
limit: 50
@@ -11,7 +11,10 @@ public class Snippet
collectionName: "{collection_name}",
prefetch:
[
new PrefetchQuery { Query = new float[] { 0.2f, 0.8f, ..., .. }, Limit = 50 }, // <-- dense vector
new PrefetchQuery {
Query = new float[] { 0.1f, 0.45f, 0.67f }, // <-- dense vector
Limit = 50
},
],
query: new Formula
{
@@ -12,11 +12,13 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Prefetch: []*qdrant.PrefetchQuery{
{
Query: qdrant.NewQuery(0.2, 0.8, .., ...), // <-- dense vector
Query: qdrant.NewQuery(0.1, 0.45, 0.67), // <-- dense vector
Limit: qdrant.PtrOf(uint64(50)),
},
},
@@ -25,10 +25,10 @@ public class Snippet {
List<ScoredPoint> time_boosted = client.queryAsync(
QueryPoints.newBuilder()
.setCollectionName({collection_name})
.setCollectionName("{collection_name}")
.addPrefetch(
PrefetchQuery.newBuilder()
.setQuery(nearest(0.2f, 0.8f, .., ..)) // <-- dense vector
.setQuery(nearest(0.1f, 0.45f, 0.67f)) // <-- dense vector
.setLimit(50)
.build())
.setQuery(
@@ -1,12 +1,12 @@
client = QdrantClient(url="http://localhost:6333") # @hide
from qdrant_client import QdrantClient, models
client = QdrantClient(url="http://localhost:6333") # @hide
time_boosted = client.query_points(
collection_name="{collection_name}",
prefetch=models.Prefetch(
query=[0.2, 0.8, ...], # <-- dense vector
query=[0.1, 0.45, 0.67], # <-- dense vector
limit=50
),
query=models.FormulaQuery(
@@ -10,7 +10,7 @@ pub async fn main() -> anyhow::Result<()> {
QueryPointsBuilder::new("{collection_name}")
.add_prefetch(
PrefetchQueryBuilder::default()
.query(vec![0.2, 0.8, .., ..]) // <-- dense vector
.query(vec![0.1, 0.45, 0.67]) // <-- dense vector
.limit(50u64),
)
.query(
@@ -2,9 +2,9 @@ import { QdrantClient } from "@qdrant/js-client-rest";
const client = new QdrantClient({ host: "localhost", port: 6333 });
const time_boosted = await client.query(collectionName, {
const time_boosted = await client.query('collectionName', {
prefetch: {
query: [0.2, 0.8, ...], // <-- dense vector
query: [0.1, 0.45, 0.67], // <-- dense vector
limit: 50
},
query: {
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
@@ -1,5 +1,5 @@
use qdrant_client::Qdrant;
use qdrant_client::qdrant::{Condition, Filter, Query, QueryPointsBuilder};
use qdrant_client::qdrant::{Query, QueryPointsBuilder};
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("http://localhost:6334").build()?;
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuerySparse(
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.1, 0.1, 0.9),
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
@@ -1,7 +1,8 @@
use qdrant_client::qdrant::{with_payload_selector::SelectorOptions, QueryPointsBuilder};
use qdrant_client::Qdrant;
pub async fn main() -> anyhow::Result<()> {
let client = qdrant_client::Qdrant::from_url("http://localhost:6334").build()?; // @hide
client
.query(
QueryPointsBuilder::new("{collection_name}")
@@ -12,6 +12,8 @@ func Main() {
Port: 6334,
})
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),