Sorting
To sort, Orama uses the properties defined in the schema
to know on which properties you want to sort.
Orama supports sorting on ‘string’, ‘number’ and ‘boolean’. The arrays are not supported.
You can also specify nested properties using the ’.’ notation: 'meta.tag'
, 'meta.rating'
and 'meta.favorite'
. For example:
Reverse order
Orama supports the reverse order specifying the key order
:
Memory optimization
By default, Orama allows the sort on all properties defined in the schema.
This creates an in-memory sort index for each properties.
If you want to optimize the memory usage, Orama supports the unsortableProperties
list.
Custom sort
Orama allows you to specify the sort algorithm in the following way:
The function accepts 2 parameter with the following format [string, number, Document]
that stands for:
- id of the document
- score of the document
- the document
Disable sort
You can disable the sort functionality using the following snippet: