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:
parent
ed6ae7e0d2
commit
267b706544
6 changed files with 11 additions and 7 deletions
|
@ -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 != "" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue