Changelog - 2026-11-04
Typesense sorts by _text_match and _eval through sortBy
New Feature Breaking ChangeIn one line. engineParams: { sortBy } sends Typesense's own sort_by, so _text_match and _eval(...) sorts work, and giving two sorts is now an error instead of one silently winning.
What changed
sortByinITypesenseTuning. Pass a Typesensesort_bystring, such as_text_match:desc,_eval([(status:=ACTIVATED):1]):desc,createdAt:desc, assortByinengineParams.search(),searchCount(),facets()andsuggest()take it.- Checked before the request. It must be a non-empty string with at most three top-level entries.
_eval(...)counts as one, however many commas it holds. Field names and the inside of_evalare left to Typesense. - One sort only.
sortBytogether withfilter.order, or withsort_by, throws.
Who is affected
- Callers that need
_text_matchor_eval. UsesortBy; the rawsort_byworkaround is no longer needed. - Callers that pass
sort_byinengineParamsand also setfilter.order. See Breaking changes. - Everyone else. No action needed. Meilisearch and the neutral
orderare unchanged.
Breaking changes
WARNING
A sort_by in engineParams used to override filter.order silently. It now throws.
Before: search({ ..., filter: { order: ['createdAt DESC'] }, engineParams: { ['sort_by']: 'name:asc' } }) sent name:asc and ignored filter.order.
After: the same call throws 'query.sortBy' and 'sort_by' both set 'sort_by' | Give it once (query.sortBy is what filter.order compiles into). Drop one of them. A sort_by that is empty, not a string, unbalanced (a stray bracket or backtick), or has more than three top-level entries also throws now. engineParams: { sortBy: undefined } is skipped, not refused.
Two smaller changes ride along. A refusal for a tuning key given twice now names the one in the query as query.<key> (for example query.numTypos, where it said numTypos), so it is told apart from the same key in engineParams. And order: [] no longer sends sort_by: ''; the search behaves the same, because Typesense treated an empty sort_by as no sort.
Details
await repository.search({
mode: 'keyword',
query: 'shoes',
queryBy: ['name'],
engineParams: {
sortBy: '_text_match:desc,_eval([(status:=ACTIVATED):1]):desc,createdAt:desc',
},
});The Typesense guide has the rules.