aboutsummaryrefslogtreecommitdiffhomepage
path: root/storage/entry_query_builder.go
diff options
context:
space:
mode:
Diffstat (limited to 'storage/entry_query_builder.go')
-rw-r--r--storage/entry_query_builder.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/storage/entry_query_builder.go b/storage/entry_query_builder.go
index 192f515..c4f6e43 100644
--- a/storage/entry_query_builder.go
+++ b/storage/entry_query_builder.go
@@ -33,6 +33,9 @@ func (e *EntryQueryBuilder) WithSearchQuery(query string) *EntryQueryBuilder {
e.conditions = append(e.conditions, fmt.Sprintf("e.document_vectors @@ plainto_tsquery($%d)", len(e.args)+1))
e.args = append(e.args, query)
}
+ // ordered by relevance, can be overrode
+ e.WithOrder(fmt.Sprintf("ts_rank(document_vectors, plainto_tsquery('%s'))", query))
+ e.WithDirection("DESC")
return e
}
@@ -315,7 +318,7 @@ func (e *EntryQueryBuilder) buildSorting() string {
var parts []string
if e.order != "" {
- parts = append(parts, fmt.Sprintf(`ORDER BY "%s"`, e.order))
+ parts = append(parts, fmt.Sprintf(`ORDER BY %s`, e.order))
}
if e.direction != "" {