I use https://laravel.com/docs/8.x/scout (sometimes PHP) with Elasticsearch making use of this great package https://github.com/babenkoivan/scout-elasticsearch-driver. This allows for the possibility of sorting / ordering records directly from Elasticsearch. Once you create your index, write a query to sort your records by a field to get the latest posts, you might be hit with the following error
{ "shard": 0, "index": "index-name", "node": "Nd1diFCdQVO9T-gx1dfazg", "reason": { "type": "query_shard_exception", "reason": "No mapping found for [field_name] in order to sort on", "index_uuid": "Rk1oQl22TH6vKzgTJCn57w", "index": "index-name"
The reason this error pops up is because you have no data in your mapping, therefore Elasticsearch cannot sort it.