fix: find songs and albums when sending an artist name search query

This commit is contained in:
Deluan 2020-02-09 19:52:06 -05:00
parent ce11a2f3be
commit 8a31e80b7a
3 changed files with 9 additions and 5 deletions

View file

@ -10,13 +10,16 @@ import (
const searchTable = "search"
func (r sqlRepository) index(id string, text string) error {
sanitizedText := strings.TrimSpace(sanitize.Accents(strings.ToLower(text)))
func (r sqlRepository) index(id string, text ...string) error {
sanitizedText := strings.Builder{}
for _, txt := range text {
sanitizedText.WriteString(strings.TrimSpace(sanitize.Accents(strings.ToLower(txt))) + " ")
}
values := map[string]interface{}{
"id": id,
"item_type": r.tableName,
"full_text": sanitizedText,
"full_text": strings.TrimSpace(sanitizedText.String()),
}
update := Update(searchTable).Where(Eq{"id": id}).SetMap(values)
count, err := r.executeSQL(update)