-
Notifications
You must be signed in to change notification settings - Fork 189
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
Service names for IndexService instances are undocumented and confusing #890
Comments
I agree with you that calling the index services by their dedicated document namespaces is somewhat confusing, as it is, this was the direction that was taken for further development of the bundle. I've already begun the work on v6.1, and I will try to find the best way to handle this, I'm considering aliases, they might even be compatible with <v6.x repository names, well see. Concerning documentation: The docs.ongr.io is not updated and still point to the documentation of the v5.x, but you should refer to the entire documentation of the bundle itself (the dedicated docs of every version of the bundle live in |
@einorler Good to know, thanks! I see now that using the name of the of the document was probably intended because you could do something like An idea would be to create a nested Symfony container called e.g. "manager" to fill the void, which would then contain all these services to keep them out of the global namespace. I was also a bit confused as to why every type now has a separate index, but I see this is the way Elasticsearch itself is going. I'll drop a link here in case anyone stumbles upon this. |
The usage of document class names for IndexService instances is indeed confusing, because usually in Symfony a class name used as service identifier means that this service is an instance of the named class. I suggest the following:
@einorler: Are you already actively working on something like this? If not I could submit a PR if you agree. |
Currently
MappingPass
registersIndexService
instances with$namespace
for each document type (or index):$namespace
is also the$class
that is set in theindexes
configuration property, which is e.g.App\Document\Office
.This is very confusing: it means the service name for the
IndexService
to manipulate offices is the name of the document class, while it isn't an instance of the document itself. This makes it look as if I'm injecting instances ofOffice
into my other services, whilst I'm actually injecting an index service forOffice
.Perhaps a BC compatible way to improve this would be to allow overriding the name and do something like
$indexesOverride[$namespace]['indexServiceName'] ?? $namespace
, which allows you to define custom names.A non-BC-compatible way would be to provide a name such as
es.index_services.app_document_office
,es.index_services.app_document_news_posts
, and so on.Also, I had to dig into the internals of this bundle to figure out what the service names were, as the documentation still shows the approach using the manager and repositories, i.e. it doesn't appear to be documented currently.
The text was updated successfully, but these errors were encountered: