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.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners