mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-14 13:49:18 +02:00
* fix(search): use LOWER/LIKE instead of ILIKE for pg_bigm 1.2 compatibility pg_bigm 1.2 on RDS does not support ILIKE index scans. Replace all ILIKE expressions with LOWER(column) LIKE LOWER(pattern) so the GIN indexes are utilized. Rebuild gin_bigm_ops indexes on LOWER() expressions. Closes MUL-482 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(search): lowercase pattern in Go, add buildSearchQuery unit tests - Lowercase phrase/terms in Go (strings.ToLower) so SQL only needs LOWER() on the column side, avoiding redundant per-query LOWER() on the pattern - Add 5 unit tests for buildSearchQuery asserting SQL shape: no ILIKE, LOWER on columns only, lowercased args, multi-term AND, number match, include-closed flag, special char escaping Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
29 lines
1.1 KiB
SQL
29 lines
1.1 KiB
SQL
-- Rebuild pg_bigm GIN indexes on LOWER() expressions so that
|
|
-- LOWER(column) LIKE pattern queries can utilize them.
|
|
-- pg_bigm 1.2 (RDS) does not support ILIKE index scans;
|
|
-- LOWER(col) LIKE LOWER(pattern) is the compatible alternative.
|
|
|
|
-- Drop old indexes that were built on raw (non-lowered) columns.
|
|
DROP INDEX IF EXISTS idx_issue_title_bigm;
|
|
DROP INDEX IF EXISTS idx_issue_description_bigm;
|
|
DROP INDEX IF EXISTS idx_comment_content_bigm;
|
|
|
|
-- Recreate indexes on LOWER() expressions.
|
|
-- Wrapped in exception handler so CI environments without pg_bigm still pass.
|
|
DO $$
|
|
BEGIN
|
|
CREATE INDEX idx_issue_title_bigm ON issue USING gin (LOWER(title) gin_bigm_ops);
|
|
CREATE INDEX idx_issue_description_bigm ON issue USING gin (LOWER(COALESCE(description, '')) gin_bigm_ops);
|
|
EXCEPTION WHEN OTHERS THEN
|
|
RAISE NOTICE 'skipping bigram indexes on issue (pg_bigm not installed)';
|
|
END
|
|
$$;
|
|
|
|
DO $$
|
|
BEGIN
|
|
CREATE INDEX idx_comment_content_bigm ON comment USING gin (LOWER(content) gin_bigm_ops);
|
|
EXCEPTION WHEN OTHERS THEN
|
|
RAISE NOTICE 'skipping bigram index on comment (pg_bigm not installed)';
|
|
END
|
|
$$;
|