Laravel scout 弹性搜索错误 500 "all shards failed"
Laravel scout Elasticsearch error 500 "all shards failed"
每当我尝试通过 Laravel 的 scout 包使用 Elasticsearch 时,我都会收到此错误。
一切都在我的本地主机上运行,因为我不必为弹性搜索设置任何节点或任何东西,但是当我尝试在我的远程服务器上做同样的事情时,这就是我得到的。
{
"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": "->"
}
]
}
这是我检索结果的方式
public function search(Request $request)
{
$products = Product::search($request->get('label'))->get();
return response()->json($products);
}
我通过 php artisan scout:import 'App\Models\Products'
导入了产品的 table 数据,它给了我一条成功消息。所以一切似乎都是正确的。
GET /_cluster/allocation/explain?pretty
给我
{
"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"
}
而“GET /_cluster/health?pretty”给了我
{
"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
}
在 windows 上一切正常,因为我需要做的就是 .\bin\elasticsearch.bat
,但 Centos 让我很头疼。
/_cluster/health
的结果表明你的单节点没有配置为数据节点。
"number_of_data_nodes": 0,
查看 中的配置,您有 node.roles: [master]
,因此这使您的节点仅作为 master
节点工作,要摄取数据,您需要一个具有角色 data
.
由于您只有一个节点,因此没有理由设置 node.roles
选项。
注释掉这一行并重启elasticsearch,它会执行一个节点可以做的所有roles。
您也可以根据需要设置为 master
和 data
节点。
node.roles: [master, data]
每当我尝试通过 Laravel 的 scout 包使用 Elasticsearch 时,我都会收到此错误。
一切都在我的本地主机上运行,因为我不必为弹性搜索设置任何节点或任何东西,但是当我尝试在我的远程服务器上做同样的事情时,这就是我得到的。
{
"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": "->"
}
]
}
这是我检索结果的方式
public function search(Request $request)
{
$products = Product::search($request->get('label'))->get();
return response()->json($products);
}
我通过 php artisan scout:import 'App\Models\Products'
导入了产品的 table 数据,它给了我一条成功消息。所以一切似乎都是正确的。
GET /_cluster/allocation/explain?pretty
给我
{
"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"
}
而“GET /_cluster/health?pretty”给了我
{
"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
}
在 windows 上一切正常,因为我需要做的就是 .\bin\elasticsearch.bat
,但 Centos 让我很头疼。
/_cluster/health
的结果表明你的单节点没有配置为数据节点。
"number_of_data_nodes": 0,
查看 node.roles: [master]
,因此这使您的节点仅作为 master
节点工作,要摄取数据,您需要一个具有角色 data
.
由于您只有一个节点,因此没有理由设置 node.roles
选项。
注释掉这一行并重启elasticsearch,它会执行一个节点可以做的所有roles。
您也可以根据需要设置为 master
和 data
节点。
node.roles: [master, data]