Reputation: 206
Whenever I try to use Elasticsearch via Laravel's scout package, I get this error.
Everything works on my localhost since I don't have to set up any node or whatsoever for elastic search but when I try to do the same thing on my remote server, this is what I get.
{
"message": "{\"error\":{\"root_cause\":[],\"type\":\"search_phase_execution_exception\",\"reason\":\"all shards failed\",\"phase\":\"query\",\"grouped\":true,\"failed_shards\":[]},\"status\":503}",
"exception": "Elasticsearch\\Common\\Exceptions\\ServerErrorResponseException",
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php",
"line": 671,
"trace": [
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php",
"line": 330,
"function": "process5xxError",
"class": "Elasticsearch\\Connections\\Connection",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/react/promise/src/FulfilledPromise.php",
"line": 28,
"function": "Elasticsearch\\Connections\\{closure}",
"class": "Elasticsearch\\Connections\\Connection",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/ezimuel/ringphp/src/Future/CompletedFutureValue.php",
"line": 55,
"function": "then",
"class": "React\\Promise\\FulfilledPromise",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/ezimuel/ringphp/src/Core.php",
"line": 341,
"function": "then",
"class": "GuzzleHttp\\Ring\\Future\\CompletedFutureValue",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php",
"line": 339,
"function": "proxy",
"class": "GuzzleHttp\\Ring\\Core",
"type": "::"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php",
"line": 235,
"function": "Elasticsearch\\Connections\\{closure}",
"class": "Elasticsearch\\Connections\\Connection",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php",
"line": 115,
"function": "performRequest",
"class": "Elasticsearch\\Connections\\Connection",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Client.php",
"line": 1587,
"function": "performRequest",
"class": "Elasticsearch\\Transport",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Client.php",
"line": 1212,
"function": "performRequest",
"class": "Elasticsearch\\Client",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/tamayo/laravel-scout-elastic/src/Engines/ElasticsearchEngine.php",
"line": 168,
"function": "search",
"class": "Elasticsearch\\Client",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/tamayo/laravel-scout-elastic/src/Engines/ElasticsearchEngine.php",
"line": 94,
"function": "performSearch",
"class": "Tamayo\\LaravelScoutElastic\\Engines\\ElasticsearchEngine",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/scout/src/Engines/Engine.php",
"line": 97,
"function": "search",
"class": "Tamayo\\LaravelScoutElastic\\Engines\\ElasticsearchEngine",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/scout/src/Builder.php",
"line": 251,
"function": "get",
"class": "Laravel\\Scout\\Engines\\Engine",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/app/Http/Controllers/ProductController.php",
"line": 15,
"function": "get",
"class": "Laravel\\Scout\\Builder",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
"line": 54,
"function": "search",
"class": "App\\Http\\Controllers\\ProductController",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
"line": 45,
"function": "callAction",
"class": "Illuminate\\Routing\\Controller",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
"line": 239,
"function": "dispatch",
"class": "Illuminate\\Routing\\ControllerDispatcher",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
"line": 196,
"function": "runController",
"class": "Illuminate\\Routing\\Route",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 685,
"function": "run",
"class": "Illuminate\\Routing\\Route",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 128,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php",
"line": 41,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Routing\\Middleware\\SubstituteBindings",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php",
"line": 59,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Routing\\Middleware\\ThrottleRequests",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 103,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 687,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 662,
"function": "runRouteWithinStack",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 628,
"function": "runRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 617,
"function": "dispatchToRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 165,
"function": "dispatch",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 128,
"function": "Illuminate\\Foundation\\Http\\{closure}",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php",
"line": 27,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php",
"line": 63,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/fruitcake/laravel-cors/src/HandleCors.php",
"line": 57,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Fruitcake\\Cors\\HandleCors",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/fideloper/proxy/src/TrustProxies.php",
"line": 57,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 167,
"function": "handle",
"class": "Fideloper\\Proxy\\TrustProxies",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 103,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 140,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 109,
"function": "sendRequestThroughRouter",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "/home/mydomain/domains/api.mydomain.dev/public_html/myproject/public/index.php",
"line": 55,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
}
]
}
Here's how I retrieve the results
public function search(Request $request)
{
$products = Product::search($request->get('label'))->get();
return response()->json($products);
}
I imported my product's table data via php artisan scout:import 'App\Models\Products'
and it gave me a success message. So everything seemed correct.
GET /_cluster/allocation/explain?pretty
gives me
{
"index": "products",
"shard": 0,
"primary": false,
"current_state": "unassigned",
"unassigned_info": {
"reason": "INDEX_CREATED",
"at": "2020-11-07T17:32:11.894Z",
"last_allocation_status": "no_attempt"
},
"can_allocate": "no",
"allocate_explanation": "cannot allocate because allocation is not permitted to any of the nodes"
}
And `GET /_cluster/health?pretty' gives me
{
"cluster_name": "myCluster",
"status": "red",
"timed_out": false,
"number_of_nodes": 1,
"number_of_data_nodes": 0,
"active_primary_shards": 0,
"active_shards": 0,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 2,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks": 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 0.0
}
Everything works on windows since all I need to do is .\bin\elasticsearch.bat
but Centos is giving me headaches.
Upvotes: 0
Views: 850
Reputation: 7463
The result of /_cluster/health
shows that your single node is not configured as data node.
"number_of_data_nodes": 0,
Looking at your config in your previous question, you have node.roles: [master]
, so this makes your node work as a master
node only, to ingest data you need a node with the role data
.
Since you have only one node, there is no reason to set the node.roles
option.
Comment this line and restart elasticsearch, it will perform all the roles that a node can do.
You can also set as a master
and data
node only if you want.
node.roles: [master, data]
Upvotes: 1