feat: enhance search with date-prioritized year filtering and true exact matching
Improve media item search functionality with two key enhancements: 1. Date-prioritized year filtering: - Prioritize date_published over copyright_year for year range queries - Fall back to copyright_year when date_published is NULL - Extract year from date_published timestamp for comparison 2. True exact search matching: - Replace ILIKE pattern matching with exact equality for quoted queries - Use search_query directly instead of wildcard pattern for exact matches - Remove SearchPattern parameter and related wildcard logic - Add COALESCE handling for author/series NULL values in exact matches These changes make year filtering more accurate with published dates and provide genuine exact matching when users wrap queries in quotes. Refs internal/database/queries/queries.sql:475, internal/services/search.go:62
This commit is contained in:
@@ -208,10 +208,10 @@ func registerFrontendRoutes(cfg *Config) {
|
||||
HasCover: pgtype.Bool{Bool: false, Valid: true}, // Changed
|
||||
SearchQuery: pgtype.Text{String: "", Valid: true}, // NEW: Required
|
||||
IsExactSearch: pgtype.Bool{Bool: false, Valid: true}, // NEW: Required
|
||||
SearchPattern: pgtype.Text{Valid: false}, // NEW: Empty for no exact search
|
||||
Sort: pgtype.Text{String: "created_at DESC", Valid: true},
|
||||
Limit: pgtype.Int4{Int32: int32(limit), Valid: true},
|
||||
Offset: pgtype.Int4{Int32: int32(offset), Valid: true},
|
||||
// SearchPattern: pgtype.Text{Valid: false}, // NEW: Empty for no exact search
|
||||
Sort: pgtype.Text{String: "created_at DESC", Valid: true},
|
||||
Limit: pgtype.Int4{Int32: int32(limit), Valid: true},
|
||||
Offset: pgtype.Int4{Int32: int32(offset), Valid: true},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user