Skip to content

Commit

Permalink
fix sql search queries
Browse files Browse the repository at this point in the history
  • Loading branch information
daronenko committed Dec 1, 2024
1 parent fb2b9ac commit 6cfa5ad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion microservices/album/repository/sql_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const (
findByQuery = `
SELECT id, name, release_date, image, artist_id, created_at, updated_at
FROM album
WHERE fts @@ to_tsquery($1)`
WHERE fts @@ to_tsquery('english', $1 || ':*')
OR fts @@ to_tsquery('russian_hunspell', $1 || ':*')`

getByArtistIDQuery = `SELECT id, name, release_date, image, artist_id, created_at, updated_at FROM album WHERE artist_id = $1`
)
3 changes: 2 additions & 1 deletion microservices/artist/repository/sql_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ const (
findByQuery = `
SELECT id, name, bio, country, image, created_at, updated_at
FROM artist
WHERE fts @@ to_tsquery($1)`
WHERE fts @@ to_tsquery('english', $1 || ':*')
OR fts @@ to_tsquery('russian_hunspell', $1 || ':*')`
)
3 changes: 2 additions & 1 deletion microservices/track/repository/sql_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const (
findByQuery = `
SELECT id, name, duration, filepath, image, artist_id, album_id, track_order_in_album, release_date, created_at, updated_at
FROM "track"
WHERE fts @@ to_tsquery($1)`
WHERE fts @@ to_tsquery('english', $1 || ':*')
OR fts @@ to_tsquery('russian_hunspell', $1 || ':*')`

getByArtistIDQuery = `SELECT id, name, duration, filepath, image, artist_id, album_id, track_order_in_album, release_date, created_at, updated_at FROM track WHERE artist_id = $1`

Expand Down

0 comments on commit 6cfa5ad

Please sign in to comment.