M admin/routes.go => admin/routes.go +1 -1
@@ 67,7 67,7 @@ func (s *Service) Autocomplete(c echo.Context) error {
s := links.ParseSearch(org)
opts := &database.FilterOptions{
Filter: sq.And{
- sq.Expr(`to_tsvector('simple', o.name || ' ' || o.slug) @@ to_tsquery('simple', ?)`, s),
+ sq.Expr(`to_tsvector('simple', o.name || ' ' || o.slug) @@ websearch_to_tsquery('simple', ?)`, s),
sq.Eq{"o.is_active": true},
},
}
M api/graph/schema.resolvers.go => api/graph/schema.resolvers.go +6 -6
@@ 4228,7 4228,7 @@ func (r *queryResolver) GetUsers(ctx context.Context, input *model.GetUserInput)
opts.Filter = sq.And{
opts.Filter,
sq.Expr(`to_tsvector('simple', u.full_name || ' ' || u.email || ' ' || o.slug)
- @@ to_tsquery('simple', ?)`, s),
+ @@ websearch_to_tsquery('simple', ?)`, s),
}
}
@@ 4373,7 4373,7 @@ func (r *queryResolver) GetOrganizations(ctx context.Context, input *model.GetOr
opts.Filter = sq.And{
opts.Filter,
sq.Expr(`to_tsvector('simple', o.name || ' ' || o.slug )
- @@ to_tsquery('simple', ?)`, s),
+ @@ websearch_to_tsquery('simple', ?)`, s),
}
}
@@ 4822,7 4822,7 @@ func (r *queryResolver) GetOrgLinks(ctx context.Context, input *model.GetLinkInp
linkOpts.Filter = sq.And{
linkOpts.Filter,
sq.Expr(`to_tsvector('simple', ol.title || ' ' || ol.description || ' ' || ol.url)
- @@ to_tsquery('simple', ?)`, s),
+ @@ websearch_to_tsquery('simple', ?)`, s),
}
}
@@ 6103,7 6103,7 @@ func (r *queryResolver) GetFeed(ctx context.Context, input *model.GetFeedInput)
linkOpts.Filter = sq.And{
linkOpts.Filter,
sq.Expr(`to_tsvector('simple', ol.title || ' ' || ol.description || ' ' || ol.url)
- @@ to_tsquery('simple', ?)`, s),
+ @@ websearch_to_tsquery('simple', ?)`, s),
}
}
@@ 6245,7 6245,7 @@ func (r *queryResolver) GetAdminOrganizations(ctx context.Context, input *model.
opts.Filter = sq.And{
opts.Filter,
sq.Expr(`to_tsvector('simple', o.name || ' ' || o.slug )
- @@ to_tsquery('simple', ?)`, s),
+ @@ websearch_to_tsquery('simple', ?)`, s),
}
}
@@ 6533,7 6533,7 @@ func (r *queryResolver) GetAdminDomains(ctx context.Context, input *model.GetAdm
opts.Filter = sq.And{
opts.Filter,
sq.Or{
- sq.Expr(`to_tsvector('simple', d.name) @@ to_tsquery('simple', ?)`, s),
+ sq.Expr(`to_tsvector('simple', d.name) @@ websearch_to_tsquery('simple', ?)`, s),
sq.ILike{"lookup_name": fmt.Sprintf("%%%s%%", *input.Search)},
},
}
M api/loaders/loaders.go => api/loaders/loaders.go +1 -1
@@ 76,7 76,7 @@ func getPopularLinks(ctx context.Context) func(key []string) ([][]*models.BaseUR
opts.Filter = sq.And{
opts.Filter,
sq.Expr(`to_tsvector('simple', b.title || ' ' || b.url)
- @@ to_tsquery('simple', ?)`, s),
+ @@ websearch_to_tsquery('simple', ?)`, s),
}
}
M core/routes.go => core/routes.go +1 -1
@@ 3217,7 3217,7 @@ func (s *Service) TagAutocomplete(c echo.Context) error {
if q != "" {
s := links.ParseSearch(q)
opts := &database.FilterOptions{
- Filter: sq.Expr(`to_tsvector('simple', t.name) @@ to_tsquery('simple', ?)`, s),
+ Filter: sq.Expr(`to_tsvector('simple', t.name) @@ websearch_to_tsquery('simple', ?)`, s),
}
if orgID != "" {
opts.Filter = sq.And{
M helpers.go => helpers.go +8 -3
@@ 800,10 800,15 @@ func (t TagQuery) GetSubQuery(inputTag, inputExcludeTag *string) (string, []inte
// We need to do some parsing to avoid systax error
// for some string chars
+//
+// Moved search to use websearch_to_tsquery so we shouldn't add any formatting to the search
+// This should probably be removed in the future.
func ParseSearch(s string) string {
- s = strings.TrimSpace(s)
- s = strings.Replace(s, ":", "\\:", -1)
- return strings.Replace(s, " ", ":* & ", -1) + ":*"
+ //s = strings.TrimSpace(s)
+ //s = strings.Replace(s, ":", "\\:", -1)
+ //return strings.Replace(s, " ", ":* & ", -1) + ":*"
+
+ return s
}
func AddQueryElement(q template.URL, param, val string) template.URL {