Break out snippets into their own files

This commit is contained in:
Abdon Pijpelink
2025-12-16 11:02:14 +01:00
parent 456a683493
commit fa168d0532
55 changed files with 556 additions and 502 deletions
@@ -0,0 +1 @@
Batch search that progressively relaxes title filters: exact `text`, then `text_any`, then no filter to return the first non-empty result set.
@@ -0,0 +1,51 @@
```http
POST /collections/books/points/query/batch
{
"searches": [
{
"query": {
"text": "time travel",
"model": "sentence-transformers/all-minilm-l6-v2"
},
"using": "description-dense",
"with_payload": true,
"filter": {
"must": [
{
"key": "title",
"match": {
"text": "time travel"
}
}
]
}
},
{
"query": {
"text": "time travel",
"model": "sentence-transformers/all-minilm-l6-v2"
},
"using": "description-dense",
"with_payload": true,
"filter": {
"must": [
{
"key": "title",
"match": {
"text_any": "time travel"
}
}
]
}
},
{
"query": {
"text": "time travel",
"model": "sentence-transformers/all-minilm-l6-v2"
},
"using": "description-dense",
"with_payload": true
}
]
}
```
@@ -0,0 +1 @@
Creates a keyword payload index on the `author` field to enable fast exact-match filtering.
@@ -0,0 +1,7 @@
```http
PUT /collections/books/index?wait=true
{
"field_name": "author",
"field_schema": "keyword"
}
```
@@ -0,0 +1 @@
Creates the `books` collection configured with a sparse vector `title-bm25` using the IDF modifier for BM25 queries.
@@ -0,0 +1,10 @@
```http
PUT /collections/books?wait=true
{
"sparse_vectors": {
"title-bm25": {
"modifier": "idf"
}
}
}
```
@@ -0,0 +1 @@
Creates the `books` collection with a dense `description-dense` vector (384 dimensions, cosine distance).
@@ -0,0 +1,11 @@
```http
PUT /collections/books
{
"vectors": {
"description-dense": {
"size": 384,
"distance": "Cosine"
}
}
}
```
@@ -0,0 +1 @@
Creates a hybrid collection combining a dense `description-dense` vector with a sparse `isbn-bm25` vector for semantic + lexical search.
@@ -0,0 +1,16 @@
```http
PUT /collections/books?wait=true
{
"vectors": {
"description-dense": {
"size": 384,
"distance": "Cosine"
}
},
"sparse_vectors": {
"isbn-bm25": {
"modifier": "idf"
}
}
}
```
@@ -0,0 +1 @@
Creates a full-text index on `title` with phrase matching and ASCII folding enabled.
@@ -0,0 +1,11 @@
```http
PUT /collections/books/index?wait=true
{
"field_name": "title",
"field_schema": {
"type": "text",
"ascii_folding": true,
"phrase_matching": true
}
}
```
@@ -0,0 +1 @@
Creates a full-text index on the `title` field with ASCII folding enabled for case-insensitive, accent-insensitive matching.
@@ -0,0 +1,10 @@
```http
PUT /collections/books/index?wait=true
{
"field_name": "title",
"field_schema": {
"type": "text",
"ascii_folding": true
}
}
```
@@ -0,0 +1 @@
Applies a phrase filter for "time machine" on titles while performing a semantic query.
@@ -0,0 +1,21 @@
```http
POST /collections/books/points/query?wait=true
{
"query": {
"text": "time travel",
"model": "sentence-transformers/all-minilm-l6-v2"
},
"using": "description-dense",
"with_payload": true,
"filter": {
"must": [
{
"key": "title",
"match": {
"phrase": "time machine"
}
}
]
}
}
```
@@ -0,0 +1 @@
Uses `text_any` to match titles containing either "space" or "war" (logical OR) while running a semantic query.
@@ -0,0 +1,21 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "space opera",
"model": "sentence-transformers/all-minilm-l6-v2"
},
"using": "description-dense",
"with_payload": true,
"filter": {
"must": [
{
"key": "title",
"match": {
"text_any": "space war"
}
}
]
}
}
```
@@ -0,0 +1 @@
Filters semantic results to titles containing the term "space".
@@ -0,0 +1,21 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "space opera",
"model": "sentence-transformers/all-minilm-l6-v2"
},
"using": "description-dense",
"with_payload": true,
"filter": {
"must": [
{
"key": "title",
"match": {
"text": "space"
}
}
]
}
}
```
@@ -0,0 +1 @@
Runs a hybrid search by prefetching dense and BM25 sparse queries for an ISBN and fusing results with Reciprocal Rank Fusion.
@@ -0,0 +1,28 @@
```http
POST /collections/books/points/query
{
"prefetch": [
{
"query": {
"text": "9780553213515",
"model": "sentence-transformers/all-minilm-l6-v2"
},
"using": "description-dense",
"score_threshold": 0.5
},
{
"query": {
"text": "9780553213515",
"model": "Qdrant/bm25"
},
"using": "isbn-bm25",
"with_payload": true
}
],
"query": {
"fusion": "rrf"
},
"limit": 10,
"with_payload": true
}
```
@@ -0,0 +1 @@
Ingests a point with a `title-bm25` sparse vector generated by the server-side `qdrant/bm25` model plus book metadata payload.
@@ -0,0 +1,21 @@
```http
PUT /collections/books/points?wait=true
{
"points": [
{
"id": 1,
"vector": {
"title-bm25": {
"text": "The Time Machine",
"model": "qdrant/bm25"
}
},
"payload": {
"title": "The Time Machine",
"author": "H.G. Wells",
"isbn": "9780553213515"
}
}
]
}
```
@@ -0,0 +1 @@
Ingests a point using the BM25 model with Spanish stemming and stopwords.
@@ -0,0 +1,24 @@
```http
PUT /collections/books/points?wait=true
{
"points": [
{
"id": 1,
"vector": {
"title-bm25": {
"text": "La Máquina del Tiempo",
"model": "qdrant/bm25",
"options": {
"language": "spanish"
}
}
},
"payload": {
"title": "La Máquina del Tiempo",
"author": "H.G. Wells",
"isbn": "9788411486880"
}
}
]
}
```
@@ -0,0 +1 @@
Ingests a book point using server-side inference to embed the description text with the `sentence-transformers/all-minilm-l6-v2` model and stores title, author, and ISBN payload.
@@ -0,0 +1,21 @@
```http
PUT /collections/books/points?wait=true
{
"points": [
{
"id": 1,
"vector": {
"description-dense": {
"text": "A Victorian scientist builds a device to travel far into the future and observes the dim trajectories of humanity. He discovers evolutionary divergence and the consequences of class division. Wells's novella established time travel as a vehicle for social commentary.",
"model": "sentence-transformers/all-minilm-l6-v2"
}
},
"payload": {
"title": "The Time Machine",
"author": "H.G. Wells",
"isbn": "9780553213515"
}
}
]
}
```
@@ -0,0 +1 @@
Runs a BM25 query with ASCII folding enabled so searches ignore diacritics (for example, matches "Mieville" and "Miéville").
@@ -0,0 +1,15 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "Mieville",
"model": "qdrant/bm25",
"options": {
"ascii_folding": true
}
},
"using": "author-bm25",
"limit": 10,
"with_payload": true
}
```
@@ -0,0 +1 @@
Tunes BM25 by setting `avg_len` to 5.0 for title fields, improving length normalization for scoring.
@@ -0,0 +1,15 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "time travel",
"model": "qdrant/bm25",
"options": {
"avg_len": 5.0
}
},
"using": "title-bm25",
"limit": 10,
"with_payload": true
}
```
@@ -0,0 +1 @@
Language-neutral BM25 query disabling stemming/stopwords, using multilingual tokenizer and ASCII folding.
@@ -0,0 +1,17 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "Mieville",
"model": "qdrant/bm25",
"options": {
"language": "none",
"tokenizer": "multilingual",
"ascii_folding": true
}
},
"using": "author-bm25",
"limit": 10,
"with_payload": true
}
```
@@ -0,0 +1 @@
Uses a BM25 query using the multilingual tokenizer to handle non-Latin scripts or languages without whitespace separation.
@@ -0,0 +1,15 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "村上春樹",
"model": "qdrant/bm25",
"options": {
"tokenizer": "multilingual"
}
},
"using": "author-bm25",
"limit": 10,
"with_payload": true
}
```
@@ -0,0 +1 @@
Uses a BM25 query with Spanish language options to match the ingest configuration for consistent tokenization, stemming, and stopwords.
@@ -0,0 +1,15 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "tiempo",
"model": "qdrant/bm25",
"options": {
"language": "spanish"
}
},
"using": "title-bm25",
"limit": 10,
"with_payload": true
}
```
@@ -0,0 +1 @@
Runs a BM25 sparse-vector query for "time travel" against the `title-bm25` vector.
@@ -0,0 +1,12 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "time travel",
"model": "qdrant/bm25"
},
"using": "title-bm25",
"limit": 10,
"with_payload": true
}
```
@@ -0,0 +1 @@
Runs a semantic query for "time travel" using the `description-dense` vector.
@@ -0,0 +1,11 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "time travel",
"model": "sentence-transformers/all-minilm-l6-v2"
},
"using": "description-dense",
"with_payload": true
}
```
@@ -0,0 +1 @@
Uses the `any` condition to filter semantic "space opera" results to points whose `author` is either Larry Niven or Jerry Pournelle (or both).
@@ -0,0 +1,21 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "space opera",
"model": "sentence-transformers/all-minilm-l6-v2"
},
"using": "description-dense",
"with_payload": true,
"filter": {
"must": [
{
"key": "author",
"match": {
"any": ["Larry Niven", "Jerry Pournelle"]
}
}
]
}
}
```
@@ -0,0 +1 @@
Semantic search for "time travel" that excludes points where the `author` payload equals `H.G. Wells`.
@@ -0,0 +1,21 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "time travel",
"model": "sentence-transformers/all-minilm-l6-v2"
},
"using": "description-dense",
"with_payload": true,
"filter": {
"must_not": [
{
"key": "author",
"match": {
"value": "H.G. Wells"
}
}
]
}
}
```
@@ -0,0 +1 @@
Semantic search for "time travel" constrained to books whose `author` payload matches `H.G. Wells` exactly.
@@ -0,0 +1,21 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "time travel",
"model": "sentence-transformers/all-minilm-l6-v2"
},
"using": "description-dense",
"with_payload": true,
"filter": {
"must": [
{
"key": "author",
"match": {
"value": "H.G. Wells"
}
}
]
}
}
```
@@ -0,0 +1 @@
Finds books related to "space opera" where both `author` filters must match: Larry Niven and Jerry Pournelle.
@@ -0,0 +1,27 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "space opera",
"model": "sentence-transformers/all-minilm-l6-v2"
},
"using": "description-dense",
"with_payload": true,
"filter": {
"must": [
{
"key": "author",
"match": {
"value": "Larry Niven"
}
},
{
"key": "author",
"match": {
"value": "Jerry Pournelle"
}
}
]
}
}
```
@@ -0,0 +1 @@
Searches for "space opera" while returning matches where either `author` is Larry Niven or Jerry Pournelle (logical OR via `should`).
@@ -0,0 +1,27 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "space opera",
"model": "sentence-transformers/all-minilm-l6-v2"
},
"using": "description-dense",
"with_payload": true,
"filter": {
"should": [
{
"key": "author",
"match": {
"value": "Larry Niven"
}
},
{
"key": "author",
"match": {
"value": "Jerry Pournelle"
}
}
]
}
}
```
@@ -0,0 +1 @@
Queries with the SPLADE++ sparse model `prithivida/splade_pp_en_v1` against the `title-splade` vector.
@@ -0,0 +1,12 @@
```http
POST /collections/books/points/query
{
"query": {
"text": "time travel",
"model": "prithivida/splade_pp_en_v1"
},
"using": "title-splade",
"limit": 10,
"with_payload": true
}
```