1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-11 17:51:01 +00:00

Sort search results by relevance

This commit is contained in:
Jebbs 2019-02-12 14:20:07 +08:00 committed by fguillot
parent ed6ae7e0d2
commit 267b706544
6 changed files with 11 additions and 7 deletions

View file

@ -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 != "" {