You can override the transformer and define your own by creating a new service. The full story can be read at http://obtao.com/blog/2014/05/advanced-indexing-with-elasticsearch-foselasticabundle/
Shortly: first you define a service like this (in my case I only index one specific entity):
myapp.elastica_to_model.transformer.company:
class: AppBundle\Transformers\ElasticaToCompanyTransformer
arguments: [ @doctrine, "AppBundle\Entity\Company" ]
calls:
- [ setPropertyAccessor, ["@fos_elastica.property_accessor"] ]
tags:
- { name: fos_elastica.elastica_to_model_transformer.app.company }
Then you create the actual service class, where you extend the original transformer and override the transform
method.
Finally you tell FosElastica to use this transformer instead of the original one:
fos_elastica:
indexes:
app:
types:
company:
mappings:
...
persistence:
...
elastica_to_model_transformer:
service: myapp.elastica_to_model.transformer.company