-
-
Notifications
You must be signed in to change notification settings - Fork 933
Description
API Platform version(s) affected: 3.0.2 (but I'm positive that this has always been an issue, our app just grew large enough for this to become an actual blocker during development)
Description
When enabling elasticsearch, all entities do a call to a non-existing elasticsearch index first before going to orm. Creating heaps of unneeded requests.
Additionally, when building the container ALL entities do a call to elasticsearch, if you have a reasonably sized API with a couple hundred doctrine entities, and only a handful of elasticsearch entities, this causes unworkable slowdowns. Each time the container needs to be rebuild (especially annoying on APP_ENV=dev), it takes a minutes on each ApiResource request.
How to reproduce
Call any non-elasticsearch entity
manual:
Install api-platform
Enable elasticsearch
Open var/log/{env}.log
repo:
clone this repo
(using docker to make things simple and consistent)
make dev
make shell
php bin/console app:create-index
php bin/console doctrine:database:create
php bin/console doctrine:schema:create
exit
docker logs -f web
Now call GET /api/doctrine_entities
You should be able to see SIX calls to _cat/indices/doctrine_entity
that all fail with an index_not_found_exception
Full log from just 1 request to GET /api/doctrine_entities
:
[2022-11-04T12:28:00.212755+01:00] request.INFO: Matched route "_api_/doctrine_entities.{_format}_get_collection". {"route":"_api_/doctrine_entities.{_format}_get_collection","route_parameters":{"_route":"_api_/doctrine_entities.{_format}_get_collection","_controller":"api_platform.action.placeholder","_format":null,"_stateless":null,"_api_resource_class":"App\\Entity\\DoctrineEntity","_api_operation_name":"_api_/doctrine_entities.{_format}_get_collection"},"request_uri":"http://a.docker/api/doctrine_entities?page=1","method":"GET"} []
[2022-11-04T12:28:00.237725+01:00] app.DEBUG: Request Body [null] []
[2022-11-04T12:28:00.237814+01:00] app.WARNING: Request Failure: {"method":"GET","uri":"http://host.docker.internal:9200/_cat/indices/doctrine_entity","port":9200,"headers":{"Host":["host.docker.internal"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.10.124-linuxkit; PHP 8.1.12)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.12,t=7.17.1,a=0,cu=7.83.1"]},"HTTP code":404,"duration":0.009591,"error":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"} []
[2022-11-04T12:28:00.238004+01:00] app.WARNING: Response ["{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"] []
[2022-11-04T12:28:00.238127+01:00] app.INFO: curl -XGET 'http://host.docker.internal:9200/_cat/indices/doctrine_entity?pretty=true' [] []
[2022-11-04T12:28:00.238215+01:00] app.DEBUG: Response: {"response":{"transfer_stats":{"url":"http://host.docker.internal/_cat/indices/doctrine_entity","content_type":"application/json; charset=UTF-8","http_code":404,"header_size":94,"request_size":276,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":0.009591,"namelookup_time":0.002747,"connect_time":0.003293,"pretransfer_time":0.003361,"size_upload":0.0,"size_download":419.0,"speed_download":43686.0,"speed_upload":0.0,"download_content_length":419.0,"upload_content_length":0.0,"starttransfer_time":0.009545,"redirect_time":0.0,"redirect_url":"","primary_ip":"192.168.65.2","certinfo":[],"primary_port":9200,"local_ip":"172.28.0.6","local_port":43906,"http_version":2,"protocol":1,"ssl_verifyresult":0,"scheme":"HTTP","appconnect_time_us":0,"connect_time_us":3293,"namelookup_time_us":2747,"pretransfer_time_us":3361,"redirect_time_us":0,"starttransfer_time_us":9545,"total_time_us":9591,"error":"","errno":0},"curl":{"error":"","errno":0},"effective_url":"http://host.docker.internal/_cat/indices/doctrine_entity","headers":{"content-type":["application/json; charset=UTF-8"],"content-length":["419"]},"version":"1.1","status":404,"reason":"Not Found","body":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"},"method":"GET","uri":"http://host.docker.internal:9200/_cat/indices/doctrine_entity","port":9200,"HTTP code":404,"duration":0.009591} []
[2022-11-04T12:28:00.241687+01:00] app.DEBUG: Request Body [null] []
[2022-11-04T12:28:00.241813+01:00] app.WARNING: Request Failure: {"method":"GET","uri":"http://host.docker.internal:9200/_cat/indices/doctrine_entity","port":9200,"headers":{"Host":["host.docker.internal"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.10.124-linuxkit; PHP 8.1.12)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.12,t=7.17.1,a=0,cu=7.83.1"]},"HTTP code":404,"duration":0.002915,"error":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"} []
[2022-11-04T12:28:00.241971+01:00] app.WARNING: Response ["{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"] []
[2022-11-04T12:28:00.242083+01:00] app.INFO: curl -XGET 'http://host.docker.internal:9200/_cat/indices/doctrine_entity?pretty=true' [] []
[2022-11-04T12:28:00.242215+01:00] app.DEBUG: Response: {"response":{"transfer_stats":{"url":"http://host.docker.internal/_cat/indices/doctrine_entity","content_type":"application/json; charset=UTF-8","http_code":404,"header_size":94,"request_size":276,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":0.002915,"namelookup_time":3.5e-5,"connect_time":3.5e-5,"pretransfer_time":9.5e-5,"size_upload":0.0,"size_download":419.0,"speed_download":143739.0,"speed_upload":0.0,"download_content_length":419.0,"upload_content_length":0.0,"starttransfer_time":0.002873,"redirect_time":0.0,"redirect_url":"","primary_ip":"192.168.65.2","certinfo":[],"primary_port":9200,"local_ip":"172.28.0.6","local_port":43906,"http_version":2,"protocol":1,"ssl_verifyresult":0,"scheme":"HTTP","appconnect_time_us":0,"connect_time_us":35,"namelookup_time_us":35,"pretransfer_time_us":95,"redirect_time_us":0,"starttransfer_time_us":2873,"total_time_us":2915,"error":"","errno":0},"curl":{"error":"","errno":0},"effective_url":"http://host.docker.internal/_cat/indices/doctrine_entity","headers":{"content-type":["application/json; charset=UTF-8"],"content-length":["419"]},"version":"1.1","status":404,"reason":"Not Found","body":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"},"method":"GET","uri":"http://host.docker.internal:9200/_cat/indices/doctrine_entity","port":9200,"HTTP code":404,"duration":0.002915} []
[2022-11-04T12:28:00.245690+01:00] app.DEBUG: Request Body [null] []
[2022-11-04T12:28:00.245769+01:00] app.WARNING: Request Failure: {"method":"GET","uri":"http://host.docker.internal:9200/_cat/indices/doctrine_entity","port":9200,"headers":{"Host":["host.docker.internal"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.10.124-linuxkit; PHP 8.1.12)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.12,t=7.17.1,a=0,cu=7.83.1"]},"HTTP code":404,"duration":0.002876,"error":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"} []
[2022-11-04T12:28:00.245984+01:00] app.WARNING: Response ["{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"] []
[2022-11-04T12:28:00.246019+01:00] app.INFO: curl -XGET 'http://host.docker.internal:9200/_cat/indices/doctrine_entity?pretty=true' [] []
[2022-11-04T12:28:00.246177+01:00] app.DEBUG: Response: {"response":{"transfer_stats":{"url":"http://host.docker.internal/_cat/indices/doctrine_entity","content_type":"application/json; charset=UTF-8","http_code":404,"header_size":94,"request_size":276,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":0.002876,"namelookup_time":3.9e-5,"connect_time":3.9e-5,"pretransfer_time":0.000134,"size_upload":0.0,"size_download":419.0,"speed_download":145688.0,"speed_upload":0.0,"download_content_length":419.0,"upload_content_length":0.0,"starttransfer_time":0.002788,"redirect_time":0.0,"redirect_url":"","primary_ip":"192.168.65.2","certinfo":[],"primary_port":9200,"local_ip":"172.28.0.6","local_port":43906,"http_version":2,"protocol":1,"ssl_verifyresult":0,"scheme":"HTTP","appconnect_time_us":0,"connect_time_us":39,"namelookup_time_us":39,"pretransfer_time_us":134,"redirect_time_us":0,"starttransfer_time_us":2788,"total_time_us":2876,"error":"","errno":0},"curl":{"error":"","errno":0},"effective_url":"http://host.docker.internal/_cat/indices/doctrine_entity","headers":{"content-type":["application/json; charset=UTF-8"],"content-length":["419"]},"version":"1.1","status":404,"reason":"Not Found","body":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"},"method":"GET","uri":"http://host.docker.internal:9200/_cat/indices/doctrine_entity","port":9200,"HTTP code":404,"duration":0.002876} []
[2022-11-04T12:28:00.250847+01:00] app.DEBUG: Request Body [null] []
[2022-11-04T12:28:00.250951+01:00] app.WARNING: Request Failure: {"method":"GET","uri":"http://host.docker.internal:9200/_cat/indices/doctrine_entity","port":9200,"headers":{"Host":["host.docker.internal"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.10.124-linuxkit; PHP 8.1.12)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.12,t=7.17.1,a=0,cu=7.83.1"]},"HTTP code":404,"duration":0.003992,"error":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"} []
[2022-11-04T12:28:00.251000+01:00] app.WARNING: Response ["{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"] []
[2022-11-04T12:28:00.251083+01:00] app.INFO: curl -XGET 'http://host.docker.internal:9200/_cat/indices/doctrine_entity?pretty=true' [] []
[2022-11-04T12:28:00.251228+01:00] app.DEBUG: Response: {"response":{"transfer_stats":{"url":"http://host.docker.internal/_cat/indices/doctrine_entity","content_type":"application/json; charset=UTF-8","http_code":404,"header_size":94,"request_size":276,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":0.003992,"namelookup_time":9.1e-5,"connect_time":9.1e-5,"pretransfer_time":0.00015,"size_upload":0.0,"size_download":419.0,"speed_download":104959.0,"speed_upload":0.0,"download_content_length":419.0,"upload_content_length":0.0,"starttransfer_time":0.003936,"redirect_time":0.0,"redirect_url":"","primary_ip":"192.168.65.2","certinfo":[],"primary_port":9200,"local_ip":"172.28.0.6","local_port":43906,"http_version":2,"protocol":1,"ssl_verifyresult":0,"scheme":"HTTP","appconnect_time_us":0,"connect_time_us":91,"namelookup_time_us":91,"pretransfer_time_us":150,"redirect_time_us":0,"starttransfer_time_us":3936,"total_time_us":3992,"error":"","errno":0},"curl":{"error":"","errno":0},"effective_url":"http://host.docker.internal/_cat/indices/doctrine_entity","headers":{"content-type":["application/json; charset=UTF-8"],"content-length":["419"]},"version":"1.1","status":404,"reason":"Not Found","body":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"},"method":"GET","uri":"http://host.docker.internal:9200/_cat/indices/doctrine_entity","port":9200,"HTTP code":404,"duration":0.003992} []
[2022-11-04T12:28:00.255052+01:00] app.DEBUG: Request Body [null] []
[2022-11-04T12:28:00.255177+01:00] app.WARNING: Request Failure: {"method":"GET","uri":"http://host.docker.internal:9200/_cat/indices/doctrine_entity","port":9200,"headers":{"Host":["host.docker.internal"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.10.124-linuxkit; PHP 8.1.12)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.12,t=7.17.1,a=0,cu=7.83.1"]},"HTTP code":404,"duration":0.003342,"error":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"} []
[2022-11-04T12:28:00.255269+01:00] app.WARNING: Response ["{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"] []
[2022-11-04T12:28:00.255452+01:00] app.INFO: curl -XGET 'http://host.docker.internal:9200/_cat/indices/doctrine_entity?pretty=true' [] []
[2022-11-04T12:28:00.255480+01:00] app.DEBUG: Response: {"response":{"transfer_stats":{"url":"http://host.docker.internal/_cat/indices/doctrine_entity","content_type":"application/json; charset=UTF-8","http_code":404,"header_size":94,"request_size":276,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":0.003342,"namelookup_time":5.1e-5,"connect_time":5.1e-5,"pretransfer_time":0.000148,"size_upload":0.0,"size_download":419.0,"speed_download":125374.0,"speed_upload":0.0,"download_content_length":419.0,"upload_content_length":0.0,"starttransfer_time":0.003282,"redirect_time":0.0,"redirect_url":"","primary_ip":"192.168.65.2","certinfo":[],"primary_port":9200,"local_ip":"172.28.0.6","local_port":43906,"http_version":2,"protocol":1,"ssl_verifyresult":0,"scheme":"HTTP","appconnect_time_us":0,"connect_time_us":51,"namelookup_time_us":51,"pretransfer_time_us":148,"redirect_time_us":0,"starttransfer_time_us":3282,"total_time_us":3342,"error":"","errno":0},"curl":{"error":"","errno":0},"effective_url":"http://host.docker.internal/_cat/indices/doctrine_entity","headers":{"content-type":["application/json; charset=UTF-8"],"content-length":["419"]},"version":"1.1","status":404,"reason":"Not Found","body":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"},"method":"GET","uri":"http://host.docker.internal:9200/_cat/indices/doctrine_entity","port":9200,"HTTP code":404,"duration":0.003342} []
[2022-11-04T12:28:00.258597+01:00] app.DEBUG: Request Body [null] []
[2022-11-04T12:28:00.258696+01:00] app.WARNING: Request Failure: {"method":"GET","uri":"http://host.docker.internal:9200/_cat/indices/doctrine_entity","port":9200,"headers":{"Host":["host.docker.internal"],"Content-Type":["application/json"],"Accept":["application/json"],"User-Agent":["elasticsearch-php/7.17.1 (Linux 5.10.124-linuxkit; PHP 8.1.12)"],"x-elastic-client-meta":["es=7.17.1,php=8.1.12,t=7.17.1,a=0,cu=7.83.1"]},"HTTP code":404,"duration":0.002657,"error":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"} []
[2022-11-04T12:28:00.258748+01:00] app.WARNING: Response ["{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"] []
[2022-11-04T12:28:00.258781+01:00] app.INFO: curl -XGET 'http://host.docker.internal:9200/_cat/indices/doctrine_entity?pretty=true' [] []
[2022-11-04T12:28:00.258950+01:00] app.DEBUG: Response: {"response":{"transfer_stats":{"url":"http://host.docker.internal/_cat/indices/doctrine_entity","content_type":"application/json; charset=UTF-8","http_code":404,"header_size":94,"request_size":276,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":0.002657,"namelookup_time":3.7e-5,"connect_time":3.7e-5,"pretransfer_time":0.000101,"size_upload":0.0,"size_download":419.0,"speed_download":157696.0,"speed_upload":0.0,"download_content_length":419.0,"upload_content_length":0.0,"starttransfer_time":0.002611,"redirect_time":0.0,"redirect_url":"","primary_ip":"192.168.65.2","certinfo":[],"primary_port":9200,"local_ip":"172.28.0.6","local_port":43906,"http_version":2,"protocol":1,"ssl_verifyresult":0,"scheme":"HTTP","appconnect_time_us":0,"connect_time_us":37,"namelookup_time_us":37,"pretransfer_time_us":101,"redirect_time_us":0,"starttransfer_time_us":2611,"total_time_us":2657,"error":"","errno":0},"curl":{"error":"","errno":0},"effective_url":"http://host.docker.internal/_cat/indices/doctrine_entity","headers":{"content-type":["application/json; charset=UTF-8"],"content-length":["419"]},"version":"1.1","status":404,"reason":"Not Found","body":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [doctrine_entity]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"doctrine_entity\",\"index_uuid\":\"_na_\",\"index\":\"doctrine_entity\"},\"status\":404}"},"method":"GET","uri":"http://host.docker.internal:9200/_cat/indices/doctrine_entity","port":9200,"HTTP code":404,"duration":0.002657} []
[2022-11-04T12:28:00.261392+01:00] security.DEBUG: Checking for authenticator support. {"firewall_name":"main","authenticators":0} []
[2022-11-04T12:28:00.292306+01:00] doctrine.INFO: Connecting with parameters array{"url":"<redacted>","driver":"pdo_mysql","host":"host.docker.internal","port":3306,"user":"root","password":"<redacted>","driverOptions":[],"defaultTableOptions":{"collation":"utf8mb4_unicode_ci"},"dbname":"myapp","serverVersion":"8.0","charset":"utf8mb4"} {"params":{"url":"<redacted>","driver":"pdo_mysql","host":"host.docker.internal","port":3306,"user":"root","password":"<redacted>","driverOptions":[],"defaultTableOptions":{"collation":"utf8mb4_unicode_ci"},"dbname":"myapp","serverVersion":"8.0","charset":"utf8mb4"}} []
[2022-11-04T12:28:00.298399+01:00] doctrine.DEBUG: Executing query: SELECT d0_.id AS id_0, d0_.my_value AS my_value_1 FROM doctrine_entity d0_ ORDER BY d0_.id ASC LIMIT 30 {"sql":"SELECT d0_.id AS id_0, d0_.my_value AS my_value_1 FROM doctrine_entity d0_ ORDER BY d0_.id ASC LIMIT 30"} []
[2022-11-04T12:28:00.304547+01:00] doctrine.DEBUG: Executing query: SELECT count(d0_.id) AS sclr_0 FROM doctrine_entity d0_ {"sql":"SELECT count(d0_.id) AS sclr_0 FROM doctrine_entity d0_"} []
[2022-11-04T12:28:00.309390+01:00] doctrine.INFO: Disconnecting [] []
Possible Solution
Allow an extra mapping parameter solely for elasticsearch so users can manually select which entities are elasticsearch, and which aren't. If this path is present, do not attempt to discover the index for every single entity in the main api_platform.mapping.paths
, but only for api_platform.elasticsearch.mapping.paths
.
Proposal:
api_platform:
mapping:
paths:
- '%kernel.project_dir%/src/Entity/'
elasticsearch:
hosts:
- '%env(ES_HOST)%'
mapping:
paths:
- '%kernel.project_dir%/src/ElasticsearchEntity/'
App\My\Custom\Mapping:
type: ...
index: ...
Or use the already existing parameter in ApiResource
that dictates whether the entity is in elasticsearch or not. I.E.
#[ApiResource(
elasticsearch: true,
normalizationContext: ['groups' => 'read']
)]
class ....
Additional Context
/