ORDER BY Functions
MAPFIELD(column, data_type)
Used to explicitly specify a mapping (by sending the 'unmapped_type' sort option) for a column that does not have a mapping associated with it, which will enable sorting on the column. By default, if a column does not have a mapping, an exception will be thrown containing an error message similar to: "No mapping found for [column] in order to sort on".
Example SQL Query:
SELECT * FROM employee ORDER BY MAPFIELD(start_date, 'long') DESCElasticsearch Sort:
{"start_date":{"order":"desc", "unmapped_type": "long"}}
- column: The column to perform the order by on.
- data_type: The Elasticsearch data type to map the column to.