mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-09 21:08:31 +02:00
Add subsection about stable ordering to pagination section (#2463)
* Add 'Stable Ordering' section to 'Pagination' section * Add FAQ entry * Small edits to the Pagination section * Apply title case to all headers on page * Small edit
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
This code snippet demonstrates how to paginate search results without duplicate points. By collecting the point IDs returned on each page and passing them to a `must_not: has_id` filter on the next request, each subsequent page excludes all previously seen results.
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
using Qdrant.Client;
|
||||
using static Qdrant.Client.Grpc.Conditions;
|
||||
|
||||
public class Snippet
|
||||
{
|
||||
public static async Task Run()
|
||||
{
|
||||
var client = new QdrantClient("localhost", 6334); // @hide
|
||||
|
||||
ulong[] seenIds = [83461, 19284, 57392, 44017, 91825]; // IDs returned on previous pages
|
||||
|
||||
// The ! operator negates the condition (must not)
|
||||
await client.QueryAsync(
|
||||
collectionName: "{collection_name}",
|
||||
query: new float[] { 0.2f, 0.1f, 0.9f, 0.7f },
|
||||
filter: !HasId(seenIds),
|
||||
limit: 5
|
||||
);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
```csharp
|
||||
using Qdrant.Client;
|
||||
using static Qdrant.Client.Grpc.Conditions;
|
||||
|
||||
ulong[] seenIds = [83461, 19284, 57392, 44017, 91825]; // IDs returned on previous pages
|
||||
|
||||
// The ! operator negates the condition (must not)
|
||||
await client.QueryAsync(
|
||||
collectionName: "{collection_name}",
|
||||
query: new float[] { 0.2f, 0.1f, 0.9f, 0.7f },
|
||||
filter: !HasId(seenIds),
|
||||
limit: 5
|
||||
);
|
||||
```
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
```go
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/qdrant/go-client/qdrant"
|
||||
)
|
||||
|
||||
seenIds := []uint64{83461, 19284, 57392, 44017, 91825} // IDs returned on previous pages
|
||||
|
||||
pointIds := make([]*qdrant.PointId, len(seenIds))
|
||||
for i, id := range seenIds {
|
||||
pointIds[i] = qdrant.NewIDNum(id)
|
||||
}
|
||||
|
||||
client.Query(context.Background(), &qdrant.QueryPoints{
|
||||
CollectionName: "{collection_name}",
|
||||
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
|
||||
Filter: &qdrant.Filter{
|
||||
MustNot: []*qdrant.Condition{
|
||||
qdrant.NewHasID(pointIds...),
|
||||
},
|
||||
},
|
||||
Limit: qdrant.PtrOf(uint64(5)),
|
||||
})
|
||||
```
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
```java
|
||||
import static io.qdrant.client.ConditionFactory.hasId;
|
||||
import static io.qdrant.client.PointIdFactory.id;
|
||||
import static io.qdrant.client.QueryFactory.nearest;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Common.Filter;
|
||||
import io.qdrant.client.grpc.Points.QueryPoints;
|
||||
import java.util.List;
|
||||
|
||||
var seenIds = List.of(id(83461), id(19284), id(57392), id(44017), id(91825)); // IDs returned on previous pages
|
||||
|
||||
client.queryAsync(
|
||||
QueryPoints.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.setQuery(nearest(0.2f, 0.1f, 0.9f, 0.7f))
|
||||
.setFilter(
|
||||
Filter.newBuilder()
|
||||
.addMustNot(hasId(seenIds))
|
||||
.build())
|
||||
.setLimit(5)
|
||||
.build())
|
||||
.get();
|
||||
```
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
```python
|
||||
from uuid import UUID
|
||||
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
seen_ids: list[int | str | UUID] = [83461, 19284, 57392, 44017, 91825] # IDs returned on previous pages
|
||||
|
||||
client.query_points(
|
||||
collection_name="{collection_name}",
|
||||
query=[0.2, 0.1, 0.9, 0.7],
|
||||
query_filter=models.Filter(
|
||||
must_not=[
|
||||
models.HasIdCondition(has_id=seen_ids),
|
||||
]
|
||||
),
|
||||
limit=5,
|
||||
)
|
||||
```
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
```rust
|
||||
use qdrant_client::qdrant::{Condition, Filter, QueryPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
let seen_ids = vec![83461u64, 19284, 57392, 44017, 91825]; // IDs returned on previous pages
|
||||
|
||||
client
|
||||
.query(
|
||||
QueryPointsBuilder::new("{collection_name}")
|
||||
.query(vec![0.2, 0.1, 0.9, 0.7])
|
||||
.filter(Filter::must_not([Condition::has_id(seen_ids)]))
|
||||
.limit(5),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
```typescript
|
||||
const seenIds = [83461, 19284, 57392, 44017, 91825]; // IDs returned on previous pages
|
||||
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
filter: {
|
||||
must_not: [
|
||||
{
|
||||
has_id: seenIds,
|
||||
},
|
||||
],
|
||||
},
|
||||
limit: 5,
|
||||
});
|
||||
```
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package snippet
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/qdrant/go-client/qdrant"
|
||||
)
|
||||
|
||||
func Main() {
|
||||
// @hide-start
|
||||
client, err := qdrant.NewClient(&qdrant.Config{
|
||||
Host: "localhost",
|
||||
Port: 6334,
|
||||
})
|
||||
|
||||
if err != nil { panic(err) }
|
||||
// @hide-end
|
||||
|
||||
seenIds := []uint64{83461, 19284, 57392, 44017, 91825} // IDs returned on previous pages
|
||||
|
||||
pointIds := make([]*qdrant.PointId, len(seenIds))
|
||||
for i, id := range seenIds {
|
||||
pointIds[i] = qdrant.NewIDNum(id)
|
||||
}
|
||||
|
||||
client.Query(context.Background(), &qdrant.QueryPoints{
|
||||
CollectionName: "{collection_name}",
|
||||
Query: qdrant.NewQuery(0.2, 0.1, 0.9, 0.7),
|
||||
Filter: &qdrant.Filter{
|
||||
MustNot: []*qdrant.Condition{
|
||||
qdrant.NewHasID(pointIds...),
|
||||
},
|
||||
},
|
||||
Limit: qdrant.PtrOf(uint64(5)),
|
||||
})
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
```http
|
||||
POST /collections/{collection_name}/points/query
|
||||
{
|
||||
"query": [0.2, 0.1, 0.9, 0.7],
|
||||
"filter": {
|
||||
"must_not": [
|
||||
{ "has_id": [83461, 19284, 57392, 44017, 91825] }
|
||||
]
|
||||
},
|
||||
"limit": 5
|
||||
}
|
||||
```
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.example.snippets_amalgamation;
|
||||
|
||||
import static io.qdrant.client.ConditionFactory.hasId;
|
||||
import static io.qdrant.client.PointIdFactory.id;
|
||||
import static io.qdrant.client.QueryFactory.nearest;
|
||||
|
||||
import io.qdrant.client.QdrantClient;
|
||||
import io.qdrant.client.QdrantGrpcClient;
|
||||
import io.qdrant.client.grpc.Common.Filter;
|
||||
import io.qdrant.client.grpc.Points.QueryPoints;
|
||||
import java.util.List;
|
||||
|
||||
public class Snippet {
|
||||
public static void run() throws Exception {
|
||||
// @hide-start
|
||||
QdrantClient client =
|
||||
new QdrantClient(QdrantGrpcClient.newBuilder("localhost", 6334, false).build());
|
||||
// @hide-end
|
||||
|
||||
var seenIds = List.of(id(83461), id(19284), id(57392), id(44017), id(91825)); // IDs returned on previous pages
|
||||
|
||||
client.queryAsync(
|
||||
QueryPoints.newBuilder()
|
||||
.setCollectionName("{collection_name}")
|
||||
.setQuery(nearest(0.2f, 0.1f, 0.9f, 0.7f))
|
||||
.setFilter(
|
||||
Filter.newBuilder()
|
||||
.addMustNot(hasId(seenIds))
|
||||
.build())
|
||||
.setLimit(5)
|
||||
.build())
|
||||
.get();
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
from uuid import UUID
|
||||
|
||||
from qdrant_client import QdrantClient, models
|
||||
|
||||
client = QdrantClient(url="http://localhost:6333") # @hide
|
||||
|
||||
seen_ids: list[int | str | UUID] = [83461, 19284, 57392, 44017, 91825] # IDs returned on previous pages
|
||||
|
||||
client.query_points(
|
||||
collection_name="{collection_name}",
|
||||
query=[0.2, 0.1, 0.9, 0.7],
|
||||
query_filter=models.Filter(
|
||||
must_not=[
|
||||
models.HasIdCondition(has_id=seen_ids),
|
||||
]
|
||||
),
|
||||
limit=5,
|
||||
)
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
use qdrant_client::qdrant::{Condition, Filter, QueryPointsBuilder};
|
||||
use qdrant_client::Qdrant;
|
||||
|
||||
pub async fn main() -> anyhow::Result<()> {
|
||||
let client = Qdrant::from_url("http://localhost:6334").build()?; // @hide
|
||||
|
||||
let seen_ids = vec![83461u64, 19284, 57392, 44017, 91825]; // IDs returned on previous pages
|
||||
|
||||
client
|
||||
.query(
|
||||
QueryPointsBuilder::new("{collection_name}")
|
||||
.query(vec![0.2, 0.1, 0.9, 0.7])
|
||||
.filter(Filter::must_not([Condition::has_id(seen_ids)]))
|
||||
.limit(5),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { QdrantClient } from "@qdrant/js-client-rest"; // @hide
|
||||
|
||||
const client = new QdrantClient({ host: "localhost", port: 6333 }); // @hide
|
||||
|
||||
const seenIds = [83461, 19284, 57392, 44017, 91825]; // IDs returned on previous pages
|
||||
|
||||
client.query("{collection_name}", {
|
||||
query: [0.2, 0.1, 0.9, 0.7],
|
||||
filter: {
|
||||
must_not: [
|
||||
{
|
||||
has_id: seenIds,
|
||||
},
|
||||
],
|
||||
},
|
||||
limit: 5,
|
||||
});
|
||||
Reference in New Issue
Block a user