From 99f4285b6e3ddbf7801738d81a727b360fada6ea Mon Sep 17 00:00:00 2001 From: ljl <17743125563@163.com> Date: Thu, 21 Dec 2023 14:23:14 +0800 Subject: [PATCH] spi-search:fix q. --- spi/spi-search/src/serv/pg/search_pg_item_serv.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/spi/spi-search/src/serv/pg/search_pg_item_serv.rs b/spi/spi-search/src/serv/pg/search_pg_item_serv.rs index 556c68f21..74378a62a 100644 --- a/spi/spi-search/src/serv/pg/search_pg_item_serv.rs +++ b/spi/spi-search/src/serv/pg/search_pg_item_serv.rs @@ -211,15 +211,19 @@ pub async fn search(search_req: &mut SearchItemSearchReq, funs: &TardisFunsInst, match search_req.query.q_scope.as_ref().unwrap_or(&SearchItemSearchQScopeKind::Title) { SearchItemSearchQScopeKind::Title => { select_fragments = ", COALESCE(ts_rank(title_tsv, query), 0::float4) AS rank_title, 0::float4 AS rank_content".to_string(); - where_fragments.push(format!("(query @@ title_tsv OR {} LIKE ${})", ext_item.field, sql_vals.len())); + where_fragments.push(format!("(query @@ title_tsv OR title LIKE ${})", sql_vals.len())); } SearchItemSearchQScopeKind::Content => { select_fragments = ", 0::float4 AS rank_title, COALESCE(ts_rank(content_tsv, query), 0::float4) AS rank_content".to_string(); - where_fragments.push(format!("(query @@ content_tsv OR {} LIKE ${})", ext_item.field, sql_vals.len())); + where_fragments.push(format!("(query @@ content_tsv OR content LIKE ${})", sql_vals.len())); } SearchItemSearchQScopeKind::TitleContent => { select_fragments = ", COALESCE(ts_rank(title_tsv, query), 0::float4) AS rank_title, COALESCE(ts_rank(content_tsv, query), 0::float4) AS rank_content".to_string(); - where_fragments.push(format!("(query @@ title_tsv OR query @@ content_tsv OR {} LIKE ${})", ext_item.field, sql_vals.len())); + where_fragments.push(format!( + "(query @@ title_tsv OR query @@ content_tsv OR title LIKE ${} OR content LIKE ${})", + sql_vals.len(), + sql_vals.len() + )); } } } else {