FOSElasticaBundle/Resources/doc/serializer.md
2013-12-17 21:17:28 +11:00

1.2 KiB

Using a Serializer in FOSElasticaBundle

FOSElasticaBundle supports using a Serializer component to serialize your objects to JSON which will be sent directly to the Elasticsearch server. Combined with automatic mapping it means types do not have to be mapped.

A) Install and declare the serializer

Follow the installation instructions for JMSSerializerBundle.

Enable the serializer configuration for the bundle:

#app/config/config.yml
fos_elastica:
    serializer: ~

The default configuration that comes with FOSElasticaBundle supports both the JMS Serializer and the Symfony Serializer. If JMSSerializerBundle is installed, additional support for serialization groups and versions are added to the bundle.

B) Set up each defined type to support serialization

A type does not need to have mappings defined when using a serializer. An example configuration for a type in this case:

fos_elastica:
    indexes:
        search:
            types:
                user:
                    serializer:
                        groups: [elastica, Default]