QQL supports multiple patterns for browsing and paginating through points.
ORDER BY — Sort by Field
Section titled “ORDER BY — Sort by Field”QUERY ORDER BY sorts by a payload field without vector similarity. It uses Qdrant's OrderBy query variant.
-- Newest firstQUERY ORDER BY created_at DESC FROM articles LIMIT 20
-- Oldest firstQUERY ORDER BY created_at ASC FROM articles LIMIT 20
-- Page 2 (offset-based)QUERY ORDER BY created_at DESC FROM articles LIMIT 20 OFFSET 20
-- With filterQUERY ORDER BY created_at DESC FROM articles WHERE status = 'published' AND category = 'engineering' LIMIT 20 OFFSET 40SCROLL — Cursor Pagination
Section titled “SCROLL — Cursor Pagination”SCROLL paginates through points using a cursor (point ID offset). It's more efficient than OFFSET for large collections.
-- Page 1SCROLL FROM docs LIMIT 20
-- Page 2 (using last point ID from page 1)SCROLL FROM docs AFTER '<point-id>' LIMIT 20
-- With filterSCROLL FROM docs WHERE topic = 'search' LIMIT 20
-- Filter + cursorSCROLL FROM docs WHERE category = 'tech' AFTER '<point-id>' LIMIT 20The response includes a next_offset field (the next cursor). Pass it as AFTER '<next_offset>' to get the next page.
SELECT — Point Lookup by ID
Section titled “SELECT — Point Lookup by ID”Retrieve a single point by ID without a vector search:
-- UUIDSELECT * FROM docs WHERE id = 'a3f8c2d1-...'
-- Integer IDSELECT * FROM docs WHERE id = 42SELECT returns the point's payload but not its vectors. Use WITH VECTORS true in a QUERY statement if you need stored vectors back.
OFFSET — Skip-Based Pagination
Section titled “OFFSET — Skip-Based Pagination”OFFSET skips results in a QUERY or SCROLL statement:
QUERY 'vector database' FROM docs LIMIT 10 OFFSET 20SCROLL FROM docs LIMIT 20 OFFSET 40Pattern Comparison
Section titled “Pattern Comparison”| Pattern | Best For |
|---|---|
QUERY ORDER BY ... OFFSET | UI list views, admin panels |
SCROLL ... AFTER '<id>' | Exporting data, large collections, ETL |
SELECT * WHERE id = ... | Single point lookup by known ID |
QUERY ... OFFSET | Paginated similarity search |
Payload and Vector Selectors
Section titled “Payload and Vector Selectors”Control what gets returned to reduce network overhead:
QUERY 'search' FROM docs LIMIT 10 WITH PAYLOAD (include = ['title', 'summary', 'url'], exclude = ['raw_text']) WITH VECTORS ('dense')| Clause | Description |
|---|---|
WITH PAYLOAD (include = ['a', 'b']) | Return only these payload fields |
WITH PAYLOAD (exclude = ['a', 'b']) | Return all payload except these |
WITH PAYLOAD false | Return no payload |
WITH PAYLOAD true | Return all payload (default) |
WITH VECTORS ('name1', 'name2') | Return specific named vectors |
WITH VECTORS true | Return all stored vectors |
WITH VECTORS false | Return no vectors (default) |