laravel-scout-opensearch
laravel-scout-opensearch copied to clipboard
OpenSearch\Common\Exceptions\Missing404Exception from scout:flush
With a Model setup as described in the README scout:import works perfectly and documents are added to OpenSearch.
But it seems that for some reason running `php artisan scout:flush "THE_MODEL" throws an exception:
OpenSearch\Common\Exceptions\Missing404Exception
Unknown 404 error from OpenSearch ""
at vendor/opensearch-project/opensearch-php/src/OpenSearch/Connections/Connection.php:656
652▕ $exception = new Unauthorized401Exception($responseBody, $statusCode);
653▕ } elseif ($statusCode === 403) {
654▕ $exception = new Forbidden403Exception($responseBody, $statusCode);
655▕ } elseif ($statusCode === 404) {
➜ 656▕ $exception = new Missing404Exception($responseBody, $statusCode);
657▕ } elseif ($statusCode === 409) {
658▕ $exception = new Conflict409Exception($responseBody, $statusCode);
659▕ } elseif ($statusCode === 400 && strpos($responseBody, 'script_lang not supported') !== false) {
660▕ $exception = new ScriptLangNotSupportedException($responseBody. $statusCode);
+24 vendor frames
25 artisan:35
Illuminate\Foundation\Console\Kernel::handle()
It looks like OpenSearch returned a 404 response with an empty body. It would be helpful if logs could be provided.
Can you add the tracer configuration to scout.opensearch and run php artisan scout:flush "THE_MODEL" again?
'tracer' => (new \Monolog\Logger('opensearch'))->pushHandler(new \Monolog\Handler\RotatingFileHandler('opensearch.log')),
The logs will be stored in the project directory in the following format:
[2023-08-24T04:44:52.804640+00:00] opensearch.INFO: curl -XPOST 'http://localhost:9200/users/_delete_by_query?pretty=true' -d '{"query":{"match_all":{}}}' [] []
[2023-08-24T04:44:52.807027+00:00] opensearch.DEBUG: Response: {"response":{"took":2,"timed_out":false,"total":0,"deleted":0,"batches":0,"version_conflicts":0,"noops":0,"retries":{"bulk":0,"search":0},"throttled_millis":0,"requests_per_second":-1.0,"throttled_until_millis":0,"failures":[]},"method":"POST","uri":"http://localhost:9200/users/_delete_by_query","port":9200,"HTTP code":200,"duration":0.007856} []
Sure thing, I will take a look at this and get the logs over ASAP.