ResultSorting
Result Sorting🔗
Description🔗
By default search results are returned ordered by relevance. By specifying a result sorting definition this default behavior can be changed and results will be sorted either by one or more field values and/or the engine score value, or by the scoring of the configured reranker.
Fields🔗
Parameter Name | Type | Description |
---|---|---|
field | string | the field name (required). Two special "fields" exist: _reranker and _score. _score means sorting by the engine score, _reranker means sorting by reranker score. For sorting with type _reranker a reranker needs to be configured. A sorting on field _reranker cannot have subsortings on other fields and cannot have a custom order. |
order | enum | (optional) order of the sorting. Allowed values are: ASCENDING, DESCENDING (case sensitive!). The default behavior depends on the data type of the field: DESCENDING for numeric and date types, ASCENDING for other types. For fields with location data type, results will be sorted according to the distance to the referenceLocation and only ASCENDING order is supported. |
referenceLocation | string | (optional1) String representation of a location point in the form of "LATITUDE LONGITUDE" (e.g. "53.3478 -6.2597"). This is used for distance sorting on a location field. |
subSorting | string | (optional) other ResultSorting object representing the sub-sorting. Nesting ResultSorting objects allows to sort on multiple fields. |
[1]: Required for fields with location data type.
Note that the default option added in the interface to sort by "relevance" equals sorting on engine score, _score (descending) with a subsorting on documentdate (descending).
Examples🔗
[
{
"field": "documentdate",
"order": "ASCENDING"
},
{
"field": "birthplace",
"referenceLocation": "52.379189,4.899431"
},
{
"field": "documentdate",
"order": "ASCENDING",
"subSorting": {
"field": "_score",
"order": "DESCENDING"
}
},
{ "field": "_reranker"}
]