Skip to content

Commit 548d43e

Browse files
committed
Add indexed_only and quantization support to search parameters
1 parent 00f1144 commit 548d43e

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

docs/search.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ Use these when you want to debug retrieval quality or tune recall without changi
107107
| `WITH { hnsw_ef: 128 }` | Increase HNSW exploration at query time |
108108
| `WITH { exact: true }` | Force exact KNN explicitly |
109109
| `WITH { acorn: true }` | Enable ACORN for filtered queries |
110-
| `WITH { indexed_only: true }` | Restrict the query to indexed segments only |
111-
| `WITH { quantization: { ... } }` | Tune quantized-search behavior at query time |
110+
| `WITH { indexed_only: true, quantization: { rescore: true } }` | Prefer indexed vectors and apply quantization controls |
112111
| `WITH { mmr_diversity: 0.5, mmr_candidates: 50 }` | Apply native MMR diversification after nearest-neighbor retrieval |
113112

114113
- `EXACT` can appear after `LIMIT` or after `RERANK`

src/qql/parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
QuantizationSearchWith,
2727
QuantizationConfig,
2828
QuantizationType,
29+
QuantizationSearchWith,
2930
RecommendStmt,
3031
SelectStmt,
3132
ScrollStmt,

tests/test_executor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,6 @@ def test_sparse_search_forwards_search_params(self, executor, mock_client, mocke
792792
search_params = mock_client.query_points.call_args.kwargs["search_params"]
793793
assert search_params.exact is True
794794
assert search_params.indexed_only is True
795-
796795
def test_dense_search_against_hybrid_collection_uses_dense_vector_name(
797796
self, executor, mock_client, mocker
798797
):

tests/test_parser.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
NotInExpr,
2323
OrExpr,
2424
QuantizationType,
25+
QuantizationSearchWith,
2526
RecommendStmt,
2627
SelectStmt,
2728
ScrollStmt,
@@ -916,13 +917,6 @@ def test_with_acorn(self):
916917
assert node.with_clause is not None
917918
assert node.with_clause.acorn is True
918919

919-
def test_with_multiple_params(self):
920-
node = parse(
921-
"SEARCH col SIMILAR TO 'q' LIMIT 5 WITH { hnsw_ef: 256, acorn: true }"
922-
)
923-
assert node.with_clause.hnsw_ef == 256
924-
assert node.with_clause.acorn is True
925-
926920
def test_with_indexed_only(self):
927921
node = parse("SEARCH col SIMILAR TO 'q' LIMIT 5 WITH { indexed_only: true }")
928922
assert node.with_clause is not None
@@ -939,6 +933,13 @@ def test_with_quantization(self):
939933
assert node.with_clause.quantization.rescore is False
940934
assert node.with_clause.quantization.oversampling == pytest.approx(2.0)
941935

936+
def test_with_multiple_params(self):
937+
node = parse(
938+
"SEARCH col SIMILAR TO 'q' LIMIT 5 WITH { hnsw_ef: 256, acorn: true }"
939+
)
940+
assert node.with_clause.hnsw_ef == 256
941+
assert node.with_clause.acorn is True
942+
942943
def test_with_mmr_params(self):
943944
node = parse(
944945
"SEARCH col SIMILAR TO 'q' LIMIT 5 "
@@ -986,6 +987,10 @@ def test_with_mmr_candidates_non_positive_raises(self):
986987
with pytest.raises(QQLSyntaxError, match="mmr_candidates must be a positive integer"):
987988
parse("SEARCH col SIMILAR TO 'q' LIMIT 5 WITH { mmr_candidates: 0 }")
988989

990+
def test_with_quantization_unknown_key_raises(self):
991+
with pytest.raises(QQLSyntaxError):
992+
parse("SEARCH col SIMILAR TO 'q' LIMIT 5 WITH { quantization: { unknown: true } }")
993+
989994
def test_with_trailing_comma(self):
990995
node = parse("SEARCH col SIMILAR TO 'q' LIMIT 5 WITH { hnsw_ef: 256, }")
991996
assert node.with_clause.hnsw_ef == 256

0 commit comments

Comments
 (0)