Merge pull request '(FIX): Fixed issues with search.' (#47) from feature/search-fixes into master
Some checks failed
Deploy application with Docker / build_and_deploy (push) Failing after 1m39s
Some checks failed
Deploy application with Docker / build_and_deploy (push) Failing after 1m39s
Reviewed-on: #47
This commit is contained in:
commit
6e96c847ec
@ -369,7 +369,27 @@ func (r *RecipeRepository) SearchRecipes(filters domain.SearchFilters, userId *i
|
||||
// Create search vector query
|
||||
var orderBy string = ""
|
||||
if filters.Search != "" {
|
||||
vector_query := strings.ReplaceAll(filters.Search, " ", " | ")
|
||||
spl := strings.Split(filters.Search, " ")
|
||||
var cleaned []string
|
||||
|
||||
// Use a string replacer, each word in the query will be passed through this
|
||||
replacer := strings.NewReplacer(
|
||||
"'", "",
|
||||
"-", "",
|
||||
"&", "",
|
||||
"|", "",
|
||||
"!", "",
|
||||
)
|
||||
|
||||
for i := range len(spl) {
|
||||
q := strings.TrimSpace(replacer.Replace(spl[i]))
|
||||
|
||||
if q != "" {
|
||||
cleaned = append(cleaned, q)
|
||||
}
|
||||
}
|
||||
|
||||
vector_query := strings.Join(cleaned, " | ")
|
||||
|
||||
conditions = append(
|
||||
conditions,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user