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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners