Handling Errors
This content is for v3.9. Switch to the latest version for up-to-date documentation.
This package returns errors that are more readable than Elasticsearch’s default responses. And embeds helpful metadata to help elucidate the issue.
QueryException
The QueryException
class will be thrown when a query fails to be executed by the Elasticsearch client. This will account for most errors.
The message will be extracted from the verbose Elasticsearch response and the details will be stored in the Exception’s details
property.
Example
Where the manufacturer.location
field has not been mapped as a geo
field:
Error Message will be: 400 Bad Request: all shards failed - failed to find geo field [manufacturer.location]
And $e->getDetails()
returns: