Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit743fd79

Browse files
authored
SDK - Patch re-ranking (#1521)
1 parent71219aa commit743fd79

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

‎pgml-sdks/pgml/src/vector_search_query_builder.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ pub async fn build_sqlx_query(
326326
SIden::Str("chunk"),
327327
SIden::Str("score"),
328328
]);
329-
query.expr_as(Expr::cust("(rank).score"),Alias::new("rank_score"));
329+
query.expr_as(Expr::cust("(rank).score"),Alias::new("rerank_score"));
330330

331331
// Build the actual select statement sub query
332332
letmut sub_query_rank_call =Query::select();
@@ -364,6 +364,20 @@ pub async fn build_sqlx_query(
364364

365365
query
366366
}else{
367+
// Wrap our query to return a fourth null column
368+
letmut vector_search_cte =CommonTableExpression::from_select(query);
369+
vector_search_cte.table_name(Alias::new(format!("{prefix}_vector_search")));
370+
ctes.push(vector_search_cte);
371+
372+
letmut query =Query::select();
373+
query
374+
.columns([
375+
SIden::Str("document"),
376+
SIden::Str("chunk"),
377+
SIden::Str("score"),
378+
])
379+
.expr_as(Expr::cust("NULL"),Alias::new("rerank_score"))
380+
.from(SIden::String(format!("{prefix}_vector_search")));
367381
query
368382
};
369383

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp