-
Notifications
You must be signed in to change notification settings - Fork 733
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
Object transformations #811
Comments
This actually mean implement analog of doctrine/mongodb-odm for elasticsearch, right? |
No. What I propose is transformation of an ODM or ORM object into an Elastica document. FOSElasticaBundle also provides a way to convert an Elastica Result object into its original ORM/ODM object but I'm not sure how useful that is for general Elastica users. |
But isn't it what ODM mean?
As general Elastica user, I bet it will be super awesome :) |
I guess it depends if you're planning on using ElasticSearch as a primary document store or not. FOSElasticaBundle doesnt make this assumption. It provides functionality that lets you populate the search indexes based on your primary document stores. The point of this feature is basically to allow the conversion of your App's BlogPost document to a representation that you can index, performing transformations on data as required by the mappings known. In a lot of cases the fields will be the same, but that isnt a safe assumption to make. Yes, this could be talk about some kind of mapper for ES, but this conversation is specifically about a service that handles a conversion, lets create a separate issue to talk about some kind of mapper if there is interest in that. |
I got it. Previously I thought that FosElastica can automagically convert Elastica document into BlogPost object, bypassing ORM mechanism. Now I have seen transformers source code. But still, mapping config, transformers and potential ODM are tight coupled. I'll try have a look how implement all this in generic way without half of Symfony's stack, if no objections will come from @ruflin or someone will take care of this. |
I'm happy to approach an initial PR if @ruflin things its worth it. I agree that the current code is too tightly coupled but the whole point of moving it upstream from FOSElastica would be to have an opportunity to do it better. We can make the symfony dependencies like PropertyAccess and ExpressionLanguage optional, and I'm not aware of any other dependencies that would be required for such a feature. |
I was thinking about this a little bit more. In the past I always mentioned that Elastica should "only" be a client. But with the introduction of the php client of elasticsearch I realise more and more, that Elastica itself is more then just a client. I started to use elasticsearch as a document store for some of my side project and I see the potential from the above mentioned functionality. I think it is more then worth to have an approach to implement this. What do you suggest under which namespace this should be implemented? |
@merk Any updates here? |
A feature that I'm looking to push upstream to Elastica is the handling of transformation between an object and its 'indexable representation'. FOSElasticaBundle provides mapping capabilities (see issue #810) which allows the bundle to accept application objects and convert them to a representation that can be sent to ElasticSearch which may not be the same.
We provide events that let the developer listen for these transformations and make changes to the final Elastica document before it is sent.
Our primary transformer is defined here: https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/Transformer/ModelToElasticaAutoTransformer.php#L60-121 but we support custom approaches in case transformations have unique requirements. Additionally, we support libraries like symfony/serializer and jms/serializer for transformation to JSON.
The text was updated successfully, but these errors were encountered: