Sorting
Order search results by field values or by relevance.
The sort search parameter takes a comma-separated list of field:direction
clauses, evaluated left to right — later clauses break ties from earlier
ones:
sort=_text_match:desc,price:asc- Each clause needs an explicit direction (
ascordesc) — there's no default direction to omit. - Only fields declared
sort: truecan be used. _text_matchis a special pseudo-field for BM25 relevance — not a real field on your documents, but always available as a sort key.- If two documents tie on every clause (or
sortis omitted and nodefault_sorting_fieldapplies), ties break on documentid.
Examples
Cheapest first:
curl 'localhost:8108/collections/products/search?q=keyboard&sort=price:asc'Most relevant first, then cheapest as a tiebreaker:
curl 'localhost:8108/collections/products/search?q=keyboard&sort=_text_match:desc,price:asc'