-
-
Notifications
You must be signed in to change notification settings - Fork 895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elasticsearch index discovery is executed when calling an orm entity, and is executed for ALL entities during container build #5115
Comments
I'm willing to attempt a PR if there's a consensus on how to get around this issue with BC, and if given some pointers at where I should start looking. |
@alanpoulain will send nudes if you manage to handle this issue and the linked PR, been struggling with the same issue for a while now. 🙏 |
Performance on requests improved 5-fold after this change and adding Thanks everyone! |
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)
Now call
GET /api/doctrine_entities
You should be able to see SIX calls to_cat/indices/doctrine_entity
that all fail with anindex_not_found_exception
Full log from just 1 request to
GET /api/doctrine_entities
: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 forapi_platform.elasticsearch.mapping.paths
.Proposal:
Or use the already existing parameter in
ApiResource
that dictates whether the entity is in elasticsearch or not. I.E.Additional Context
/
The text was updated successfully, but these errors were encountered: