|
|
@@ -137,7 +137,9 @@ Relation names are per-project and **unqualified**: requests and responses alway
|
|
|
Requires a `kind=vector` collection. Vectors are stored with cosine-similarity indexing.
|
|
|
|
|
|
- `POST /api/v1/projects/{project}/collections/{name}/vectors` `{id?, text?, vector?, metadata?}` - Store a vector. Supply either `text` (the server embeds it, resolving the model as: the collection's `embedding_model` pin, else the project's embedding override, else the global default) or a pre-computed `vector` array. `vector` dimension must match the collection's `vector_dimension`. `metadata` is an arbitrary JSON object stored alongside the vector.
|
|
|
-- `POST /api/v1/projects/{project}/collections/{name}/search` `{query_text?, query_vector?, top_k?, min_score?, filters?}` - Cosine-similarity search. Supply either `query_text` or `query_vector`; neither is **422**. `top_k` caps the results, **default 5**. `min_score` (0-1) drops low-confidence matches, default 0. `filters` is an array of `field:op:value` strings applied to the vector's metadata, using the grammar and operators above - metadata is stored at the top level of the document, so a vector written with `metadata:{"colour":"red"}` is filtered as `colour:eq:red`. The response also carries **`scan_capped`** and `scanned` (plus `scan_cap` when capped). **Against database 2.14.0 or newer a filtered search is a single server-side call: the filter selects candidates BEFORE ranking, so the answer is the exact top-K among matching rows, there is no scan cap, `scan_capped` is always `false` and `scanned` is `0`** - and it is FASTER than the same search unfiltered, because only matching rows are scored. Against an older server the service falls back to walking the ranking `scan_cap` deep, and there a filter whose matches lie deeper than the walk returns FEWER hits than match, which is what `scan_capped: true` reports. `scan_capped: false` always means the answer is complete; on 2.14.0+ it is complete by construction, on the fallback it means complete this time. **On the fallback, check it before treating a filtered result set as exhaustive.** Note `min_score` defaults to 0, which drops rows whose cosine is NEGATIVE - pass a negative `min_score` to see every match. Rows with equal scores are ordered by id, lowest first. Inside a function the return stays an array and a truncation warning goes to the run's console instead.
|
|
|
+- `POST /api/v1/projects/{project}/collections/{name}/search` `{query_text?, query_vector?, top_k?, min_score?, filters?}` - Cosine-similarity search. Supply either `query_text` or `query_vector`; neither is **422**. `top_k` caps the results, **default 5**. `min_score` (0-1) drops low-confidence matches, default 0. `filters` is an array of `field:op:value` strings applied to the vector's metadata, using the grammar and operators above - metadata is stored at the top level of the document, so a vector written with `metadata:{"colour":"red"}` is filtered as `colour:eq:red`. The response also carries **`scan_capped`** and `scanned` (plus `scan_cap` when capped). **UPGRADE NOTE: a filtered search may now return MORE rows than it did before, and that is the fix rather than a break.** On the old capped path a filter whose matches lay deeper than the walk returned fewer hits than matched - one collection measured 426 rows for a filter with ~553 true matches at `top_k: 500`. On 2.14.0 the same query returns the full 500. So `top_k` now bounds a COMPLETE set rather than a truncated one, and code that was tuned around the smaller number - a page size, a display limit, a loop termination, a count treated as a ceiling - will see the larger one. If you built against the capped behaviour, check those before concluding a filter stopped filtering.
|
|
|
+
|
|
|
+**Against database 2.14.0 or newer a filtered search is a single server-side call: the filter selects candidates BEFORE ranking, so the answer is the exact top-K among matching rows, there is no scan cap, `scan_capped` is always `false` and `scanned` is `0`** - and it is FASTER than the same search unfiltered, because only matching rows are scored. Against an older server the service falls back to walking the ranking `scan_cap` deep, and there a filter whose matches lie deeper than the walk returns FEWER hits than match, which is what `scan_capped: true` reports. `scan_capped: false` always means the answer is complete; on 2.14.0+ it is complete by construction, on the fallback it means complete this time. **On the fallback, check it before treating a filtered result set as exhaustive.** Note `min_score` defaults to 0, which drops rows whose cosine is NEGATIVE - pass a negative `min_score` to see every match. Rows with equal scores are ordered by id, lowest first. Inside a function the return stays an array and a truncation warning goes to the run's console instead.
|
|
|
|
|
|
Filtering is evaluated by the database, then intersected with the similarity ranking, so scores are identical with and without a filter and `min_score` means the same thing either way. The scan is bounded at 10000 candidates: within a collection of that size a filtered search returns exactly the true top-k, and beyond it a filter matching only very low-ranked vectors may return fewer.
|
|
|
|