@@ -918,9 +918,10 @@ function hydrateSearchCandidates(
918918) {
919919 const accessCondition = knowledgeAccessCondition ( access )
920920 /**
921- * The score comes from the projection's stored halfvec, the column the walk ranked on: the
922- * original vector lives out of line in toast storage that no cache holds, and reading it back
923- * for every hydrated row was a random page read per result on every novel query.
921+ * The projection joins so a condition on its stored halfvec — the candidate threshold — can be
922+ * tested here; the returned score is whatever the leg passes as `distance`. Both legs pass the
923+ * original vector's cosine distance: one out-of-line read per hydrated row, the page's size,
924+ * where scoring the whole candidate pool that way read one per candidate on every novel query.
924925 */
925926 return runSearchQuery ( budget , `${ leg } .sql` , ( executor ) =>
926927 executor
@@ -1648,7 +1649,7 @@ const SOURCE_RANKING_CONCURRENCY = 3
16481649 */
16491650async function selectVectorResults ( params : SearchParams ) : Promise < SearchResult [ ] > {
16501651 const queryVector = params . queryVector !
1651- /** One score for ranking, threshold and results alike: the projection's, which stays in cache. */
1652+ /** The walk and the candidate threshold use the projection's score , which stays in cache; the page is scored on the original vectors at hydration . */
16521653 const distance = embeddingCandidateDistance (
16531654 queryVector . dimensions ,
16541655 queryVector . vector ,
@@ -2279,18 +2280,14 @@ export async function executeKeywordSearch(params: KeywordSearchParams): Promise
22792280 } ,
22802281 /**
22812282 * Every candidate already matched the query where it was ranked; matching it again here
2282- * would detoast one text-search vector per result. The score is the projection 's, like the
2283- * vector leg's, so the two legs fuse on the same distance.
2283+ * would detoast one text-search vector per result. The score is the original vector 's, like
2284+ * the vector leg's, so one response carries one distance scale .
22842285 */
22852286 hydrate : ( ids , authorized ) =>
22862287 hydrateSearchCandidates (
22872288 ids ,
22882289 authorized ,
2289- embeddingCandidateDistance (
2290- queryVector . dimensions ,
2291- queryVector . vector ,
2292- queryVector . model
2293- ) . as ( 'distance' ) ,
2290+ embeddingDistance ( queryVector . dimensions , queryVector . vector ) . as ( 'distance' ) ,
22942291 params . filters ,
22952292 [ inArray ( embedding . knowledgeBaseId , knowledgeBaseIds ) , ...tagFilterConditions ] ,
22962293 'keyword' ,
0 commit comments