Skip to content

Commit ec351ff

Browse files
committed
Working site search with doc type filtering
1 parent 59f4419 commit ec351ff

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pgml-sdks/pgml/src/collection.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,19 @@ impl Collection {
718718
}
719719
}
720720

721+
#[instrument(skip(self))]
722+
pub async fn search_local(
723+
&self,
724+
query: Json,
725+
pipeline: &MultiFieldPipeline,
726+
) -> anyhow::Result<Vec<Json>> {
727+
let pool = get_or_initialize_pool(&self.database_url).await?;
728+
let (built_query, values) = build_search_query(self, query.clone(), pipeline).await?;
729+
let results: Vec<(Json,)> = sqlx::query_as_with(&built_query, values)
730+
.fetch_all(&pool)
731+
.await?;
732+
Ok(results.into_iter().map(|v| v.0).collect())
733+
}
721734
/// Performs vector search on the [Collection]
722735
///
723736
/// # Arguments

pgml-sdks/pgml/src/search_query_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ pub async fn build_search_query(
307307
.expr(Expr::cust("*"))
308308
.from_subquery(query, Alias::new("q1"))
309309
.order_by(SIden::Str("score"), Order::Desc)
310-
.limit(5);
310+
.limit(limit);
311311

312312
let mut combined_query = Query::select();
313313
combined_query

0 commit comments

Comments
 (0)