mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 13:07:36 +03:00
feat: search in WebUI now is more flexible, searching in all relevant fields in the current view
This commit is contained in:
parent
32fbf2e9eb
commit
8401d85f78
6 changed files with 25 additions and 6 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/deluan/navidrome/model"
|
||||
"github.com/deluan/rest"
|
||||
"github.com/google/uuid"
|
||||
"github.com/kennygrant/sanitize"
|
||||
)
|
||||
|
||||
type filterFunc = func(field string, value interface{}) Sqlizer
|
||||
|
@ -249,3 +250,17 @@ func booleanFilter(field string, value interface{}) Sqlizer {
|
|||
v := strings.ToLower(value.(string))
|
||||
return Eq{field: strings.ToLower(v) == "true"}
|
||||
}
|
||||
|
||||
func fullTextFilter(field string, value interface{}) Sqlizer {
|
||||
q := value.(string)
|
||||
q = strings.TrimSpace(sanitize.Accents(strings.ToLower(strings.TrimSuffix(q, "*"))))
|
||||
parts := strings.Split(q, " ")
|
||||
filters := And{}
|
||||
for _, part := range parts {
|
||||
filters = append(filters, Or{
|
||||
Like{"full_text": part + "%"},
|
||||
Like{"full_text": "%" + part + "%"},
|
||||
})
|
||||
}
|
||||
return filters
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue