fix: use ILIKE substring search instead of full-text stemming
Author: Aaron Steven White
Commit
7e01f823b9d30618301a391893d1060035ae55e3Parent: b8127a4fdf
Structural diff unavailable
These commits were pushed via plain git push, so no pre-parsed
schemas are available. Install git-remote-cospan and re-push via panproto:// to
see scope-level changes, breaking change detection, and semantic diffs.
brew install panproto/tap/git-remote-cospan1 file changed +17 -39
@@ -191,44 +191,22 @@ pub async fn search(
191191 query: &str, 192192 source: Option<&str>, 193193 limit: i64, 194- cursor: Option<&str>, 194+ _cursor: Option<&str>, 195195 ) -> Result<Vec<RepoRow>, sqlx::Error> { 196- let source_clause = if source.is_some() { "AND source = $4" } else { "" }; 197- if let Some(cursor_ts) = cursor { 198- let ts: DateTime<Utc> = cursor_ts 199- .parse() 200- .map_err(|_| sqlx::Error::Protocol("invalid cursor".into()))?; 201- let sql = format!( 202- "SELECT did, rkey, name, description, protocol, node_did, node_url, \ 203- default_branch, visibility, source_repo, star_count, fork_count, \ 204- open_issue_count, open_mr_count, source, source_uri, created_at, indexed_at \ 205- FROM repos \ 206- WHERE to_tsvector('english', coalesce(name, '') || ' ' || coalesce(description, '')) \ 207- @@ plainto_tsquery('english', $1) \ 208- AND created_at < $2 {source_clause} \ 209- ORDER BY star_count DESC, created_at DESC LIMIT $3" 210- ); 211- let mut q = sqlx::query_as::<_, RepoRow>(&sql) 212- .bind(query) 213- .bind(ts) 214- .bind(limit); 215- if let Some(s) = source { q = q.bind(s); } 216- q.fetch_all(pool).await 217- } else { 218- let source_clause = if source.is_some() { "AND source = $3" } else { "" }; 219- let sql = format!( 220- "SELECT did, rkey, name, description, protocol, node_did, node_url, \ 221- default_branch, visibility, source_repo, star_count, fork_count, \ 222- open_issue_count, open_mr_count, source, source_uri, created_at, indexed_at \ 223- FROM repos \ 224- WHERE to_tsvector('english', coalesce(name, '') || ' ' || coalesce(description, '')) \ 225- @@ plainto_tsquery('english', $1) {source_clause} \ 226- ORDER BY star_count DESC, created_at DESC LIMIT $2" 227- ); 228- let mut q = sqlx::query_as::<_, RepoRow>(&sql) 229- .bind(query) 230- .bind(limit); 231- if let Some(s) = source { q = q.bind(s); } 232- q.fetch_all(pool).await 233- } 196+ let pattern = format!("%{query}%"); 197+ let source_clause = if source.is_some() { "AND source = $3" } else { "" }; 198+ let sql = format!( 199+ "SELECT did, rkey, name, description, protocol, node_did, node_url, \ 200+ default_branch, visibility, source_repo, star_count, fork_count, \ 201+ open_issue_count, open_mr_count, source, source_uri, created_at, indexed_at \ 202+ FROM repos \ 203+ WHERE (name ILIKE $1 OR coalesce(description, '') ILIKE $1) \ 204+ {source_clause} \ 205+ ORDER BY star_count DESC, created_at DESC LIMIT $2" 206+ ); 207+ let mut q = sqlx::query_as::<_, RepoRow>(&sql) 208+ .bind(&pattern) 209+ .bind(limit); 210+ if let Some(s) = source { q = q.bind(s); } 211+ q.fetch_all(pool).await 234212 }