Search code examples
symfonyelasticsearchfoselasticabundle

Can you have two or more types defined in different indexes for the same entity?


I’m using Elasticsearch 0.9 with FOSElasticaBundle 3.0.0.alpha6 and Symfony 2.5.10. Will FOSElastica Listener keep all indexes updated? Can I define different listener services for each environment? I'm asking to see if I can use different indexes for the production, development and test environments.


Solution

  • Will FOSElastica Listener keep all indexes updated

    Yes, if you will configure persistence section properly in your config file.

    Can I define different listener services for each environment? I'm asking to see if I can use different indexes for the production, development and test environments.

    If I understand you well, the solution for that is here. You can just set other index name in each environment's config (prod, dev, test).

    Or even better, you can use kernel.env parameter to dynamically change used indexes depending on current environment:

    #app/config/config.yml
    fos_elastica:
        indexes:
            app:
                index_name: app_%kernel.env%