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
@@ -2,7 +2,6 @@ package snippet
import (
"context"
"time"
"github.com/qdrant/go-client/qdrant"
)
@@ -15,7 +14,9 @@ func Main() {
UseTLS: true,
})
client.Query(ctx, &qdrant.QueryPoints{
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{
@@ -6,6 +6,7 @@ import static io.qdrant.client.ValueFactory.value;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Points.Document;
import io.qdrant.client.grpc.Points.QueryPoints;
import java.util.Map;
public class Snippet {
@@ -18,7 +19,7 @@ public class Snippet {
client
.queryAsync(
Points.QueryPoints.newBuilder()
QueryPoints.newBuilder()
.setCollectionName("{collection_name}")
.setQuery(
nearest(
@@ -1,5 +1,5 @@
use qdrant_client::{
Qdrant, QdrantError,
Qdrant,
qdrant::{Document, Query, QueryPointsBuilder, Value},
};
use std::collections::HashMap;
@@ -2,7 +2,6 @@ package snippet
import (
"context"
"time"
"github.com/qdrant/go-client/qdrant"
)
@@ -15,7 +14,9 @@ func Main() {
UseTLS: true,
})
client.Upsert(ctx, &qdrant.UpsertPoints{
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
{
@@ -1,5 +1,5 @@
use qdrant_client::{
Payload, Qdrant, QdrantError,
Payload, Qdrant,
qdrant::{Document, PointStruct, UpsertPointsBuilder},
};
use std::collections::HashMap;
@@ -2,7 +2,6 @@ package snippet
import (
"context"
"time"
"github.com/qdrant/go-client/qdrant"
)
@@ -15,7 +14,9 @@ func Main() {
UseTLS: true,
})
client.Upsert(ctx, &qdrant.UpsertPoints{
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
{
@@ -7,6 +7,7 @@ import static io.qdrant.client.VectorsFactory.namedVectors;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Points.Document;
import io.qdrant.client.grpc.Points.Image;
import io.qdrant.client.grpc.Points.PointStruct;
import java.util.List;
@@ -1,24 +1,26 @@
use qdrant_client::{
Payload, Qdrant, QdrantError,
qdrant::{Document, PointStruct, UpsertPointsBuilder},
Payload, Qdrant,
qdrant::{DocumentBuilder, PointStruct, UpsertPointsBuilder},
};
use std::collections::HashMap;
pub async fn main() -> anyhow::Result<()> {
let client = Qdrant::from_url("<your-qdrant-url>").build()?;
client
.upsert_points(UpsertPointsBuilder::new("{collection_name}",
vec![
PointStruct::new(1,
HashMap::from([("my-bm25-vector".to_string(),
Document {
text: "Recipe for baking chocolate chip cookies".into(),
model: "qdrant/bm25".into(),
..Default::default()
}.into())]),
Payload::default())
]))
.await?;
.upsert_points(UpsertPointsBuilder::new(
"{collection_name}",
vec![PointStruct::new(
1,
HashMap::from([(
"my-bm25-vector".to_string(),
DocumentBuilder::new("Recipe for baking chocolate chip cookies", "qdrant/bm25")
.build(),
)]),
Payload::default(),
)],
))
.await?;
Ok(())
}
@@ -2,7 +2,6 @@ package snippet
import (
"context"
"time"
"github.com/qdrant/go-client/qdrant"
)
@@ -15,7 +14,9 @@ func Main() {
UseTLS: true,
})
client.Query(ctx, &qdrant.QueryPoints{
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{
@@ -6,6 +6,7 @@ import static io.qdrant.client.ValueFactory.value;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Points.Document;
import io.qdrant.client.grpc.Points.QueryPoints;
import java.util.Map;
public class Snippet {
@@ -17,7 +18,7 @@ public class Snippet {
.build());
client
.queryAsync(
Points.QueryPoints.newBuilder()
QueryPoints.newBuilder()
.setCollectionName("{collection_name}")
.setQuery(
nearest(
@@ -1,5 +1,5 @@
use qdrant_client::{
Qdrant, QdrantError,
Qdrant,
qdrant::{Document, Query, QueryPointsBuilder, Value},
};
use std::collections::HashMap;
@@ -2,7 +2,6 @@ package snippet
import (
"context"
"time"
"github.com/qdrant/go-client/qdrant"
)
@@ -15,7 +14,9 @@ func Main() {
UseTLS: true,
})
client.Upsert(ctx, &qdrant.UpsertPoints{
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
{
@@ -1,5 +1,5 @@
use qdrant_client::{
Payload, Qdrant, QdrantError,
Payload, Qdrant,
qdrant::{Image, PointStruct, UpsertPointsBuilder},
};
use std::collections::HashMap;
@@ -2,7 +2,6 @@ package snippet
import (
"context"
"time"
"github.com/qdrant/go-client/qdrant"
)
@@ -15,7 +14,9 @@ func Main() {
UseTLS: true,
})
client.Upsert(ctx, &qdrant.UpsertPoints{
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
{
@@ -1,6 +1,6 @@
use qdrant_client::{
Payload, Qdrant, QdrantError,
qdrant::{Document, PointStruct, UpsertPointsBuilder, Vectors},
Payload, Qdrant,
qdrant::{Document, Image, NamedVectors, PointStruct, UpsertPointsBuilder},
};
use std::collections::HashMap;
@@ -2,7 +2,6 @@ package snippet
import (
"context"
"time"
"github.com/qdrant/go-client/qdrant"
)
@@ -15,7 +14,9 @@ func Main() {
UseTLS: true,
})
client.Query(ctx, &qdrant.QueryPoints{
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{
@@ -6,6 +6,7 @@ import static io.qdrant.client.ValueFactory.value;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.Points.Document;
import io.qdrant.client.grpc.Points.QueryPoints;
import java.util.Map;
public class Snippet {
@@ -17,7 +18,7 @@ public class Snippet {
.build());
client
.queryAsync(
Points.QueryPoints.newBuilder()
QueryPoints.newBuilder()
.setCollectionName("{collection_name}")
.setQuery(
nearest(
@@ -1,5 +1,5 @@
use qdrant_client::{
Qdrant, QdrantError,
Qdrant,
qdrant::{Document, Query, QueryPointsBuilder, Value},
};
use std::collections::HashMap;
@@ -2,7 +2,6 @@ package snippet
import (
"context"
"time"
"github.com/qdrant/go-client/qdrant"
)
@@ -15,7 +14,9 @@ func Main() {
UseTLS: true,
})
client.Upsert(ctx, &qdrant.UpsertPoints{
if err != nil { panic(err) } // @hide
client.Upsert(context.Background(), &qdrant.UpsertPoints{
CollectionName: "{collection_name}",
Points: []*qdrant.PointStruct{
{
@@ -1,5 +1,5 @@
use qdrant_client::{
Payload, Qdrant, QdrantError,
Payload, Qdrant,
qdrant::{Document, PointStruct, UpsertPointsBuilder},
};
use std::collections::HashMap;
@@ -2,7 +2,6 @@ package snippet
import (
"context"
"time"
"github.com/qdrant/go-client/qdrant"
)
@@ -15,7 +14,9 @@ func Main() {
UseTLS: true,
})
client.Query(ctx, &qdrant.QueryPoints{
if err != nil { panic(err) } // @hide
client.Query(context.Background(), &qdrant.QueryPoints{
CollectionName: "{collection_name}",
Query: qdrant.NewQueryNearest(
qdrant.NewVectorInputDocument(&qdrant.Document{
@@ -1,5 +1,5 @@
use qdrant_client::{
Qdrant, QdrantError,
Qdrant,
qdrant::{Document, Query, QueryPointsBuilder},
};