Display recent entries first in search results
This commit is contained in:
parent
d2f4ed93df
commit
c0e407e156
1 changed files with 3 additions and 1 deletions
|
@ -32,7 +32,9 @@ func (e *EntryQueryBuilder) WithSearchQuery(query string) *EntryQueryBuilder {
|
||||||
nArgs := len(e.args) + 1
|
nArgs := len(e.args) + 1
|
||||||
e.conditions = append(e.conditions, fmt.Sprintf("e.document_vectors @@ plainto_tsquery($%d)", nArgs))
|
e.conditions = append(e.conditions, fmt.Sprintf("e.document_vectors @@ plainto_tsquery($%d)", nArgs))
|
||||||
e.args = append(e.args, query)
|
e.args = append(e.args, query)
|
||||||
e.WithOrder(fmt.Sprintf("ts_rank(document_vectors, plainto_tsquery($%d))", nArgs))
|
|
||||||
|
// 0.0000001 = 0.1 / (seconds_in_a_day)
|
||||||
|
e.WithOrder(fmt.Sprintf("ts_rank(document_vectors, plainto_tsquery($%d)) - extract (epoch from now() - published_at)::float * 0.0000001", nArgs))
|
||||||
e.WithDirection("DESC")
|
e.WithDirection("DESC")
|
||||||
}
|
}
|
||||||
return e
|
return e
|
||||||
|
|
Loading…
Add table
Reference in a new issue