Skip to content

feat: add RECOMMEND statement for point recommendations#14

Merged
pavanjava merged 2 commits into
pavanjava:mainfrom
srimon12:feat/recommend
Apr 23, 2026
Merged

feat: add RECOMMEND statement for point recommendations#14
pavanjava merged 2 commits into
pavanjava:mainfrom
srimon12:feat/recommend

Conversation

@srimon12
Copy link
Copy Markdown
Collaborator

Summary

  1. Adds first-class RECOMMEND support to QQL, plus explicit IDs on INSERT/INSERT BULK for deterministic upserts.
  2. Maps recommendation queries to Qdrant’s RecommendQuery with positive/negative IDs, optional strategy, and optional WHERE.
  3. Preserves IDs in .qql dumps and makes script splitting recognize RECOMMEND.
  4. added a resources/sample_v2.qql that showcases dense search, filters, query-time params, recommend, hybrid, and sparse search.
  5. Fixes write visibility issues by using wait=True on writes and waiting for new collections to become visible before continuing.
  6. Also cleans up Windows console output to avoid Unicode encoding failures in script/dump flows.

Validation

uv run pytest tests/test_parser.py tests/test_executor.py tests/test_script.py tests/test_dumper.py
uv run qql execute resources\sample_v2.qql --stop-on-error
Live local Qdrant verification: qql_sample_v2=6, qql_sample_v2_hybrid=3

- Introduced the RECOMMEND statement to allow users to find similar points based on known examples.
- Implemented parsing, execution, and filtering logic for the RECOMMEND statement in the QQL parser and executor.
- Updated the CLI to include documentation for the new RECOMMEND statement.
- Enhanced the executor to handle positive and negative IDs, as well as optional query filters and strategies.
- Added tests for the RECOMMEND statement to ensure correct functionality and error handling.
- Updated the sample QQL script to demonstrate the usage of the RECOMMEND statement.
Add OFFSET, SCORE THRESHOLD, WITH clause, LOOKUP FROM, and USING
to RECOMMEND statements, closing the gap with the Qdrant query_points
recommend surface.

Parser:
- Parse LOOKUP FROM <collection> [VECTOR '<name>'] for cross-collection
  recommendation
- Parse USING '<vector_name>' to target a specific named vector
- Parse OFFSET <n> for pagination
- Parse SCORE THRESHOLD <f> for minimum score filtering
- Parse WITH { exact: true, hnsw_ef: <n> } for query-time search params

Executor:
- Wire offset, score_threshold, search_params, using, and lookup_from
  to Qdrant query_points()
- Use LookupLocation for cross-collection ID lookups

Tests:
- Parser coverage for all new clauses and combined forms
- Executor coverage verifying forwarding to the Qdrant client

Docs:
- Update README with full RECOMMEND syntax reference
- Update sample_v2.qql with OFFSET, SCORE THRESHOLD, WITH, and USING
  examples
@srimon12
Copy link
Copy Markdown
Collaborator Author

Update — Full Qdrant Recommend API surface now covered

The second commit (feat: Full Qdrant Recommend API support) extends the baseline RECOMMEND with every query-time knob Qdrant exposes for recommendations:

New clause What it does
OFFSET <n> Pagination — skip the first N results.
SCORE THRESHOLD <f> Drop recommendations below a confidence cutoff.
WITH { exact: true, hnsw_ef: <n> } Exact KNN baseline or HNSW tuning for recommend queries.
LOOKUP FROM <collection> [VECTOR '<name>'] Look up positive/negative IDs from a different collection.
USING '<vector_name>' Target a specific named vector in the result collection (e.g., USING 'sparse').

Clause order:

RECOMMEND FROM <collection>
  POSITIVE IDS (<id>, ...)
  [NEGATIVE IDS (<id>, ...)]
  [STRATEGY '<strategy>']
  [LOOKUP FROM <collection> [VECTOR '<name>']]
  [USING '<vector_name>']
  LIMIT <n>
  [OFFSET <n>]
  [SCORE THRESHOLD <f>]
  [WHERE <filter>]
  [WITH { exact: true, hnsw_ef: <n> }]

Docs updated:

  • README.md — full syntax reference with examples for all new clauses.
  • resources/sample_v2.qql — added OFFSET, SCORE THRESHOLD, WITH, and USING examples.

Tests:

  • tests/test_parser.py — 74 new lines covering all clause combinations.
  • tests/test_executor.py — 105 new lines verifying forwarding to the Qdrant client mock.
  • All 336 tests pass.

@pavanjava pavanjava merged commit 1abc8c4 into pavanjava:main Apr 23, 2026
2 checks passed
@pavanjava
Copy link
Copy Markdown
Owner

Thanks for the feature enrichment contribution and PR.

@srimon12 srimon12 deleted the feat/recommend branch April 24, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants