Question

I'm using Elasticsearch and Symfony2 in a system via FOSElasticaBundle.

While I was using only one server it was ok to configure the clients config like this: https://github.com/FriendsOfSymfony/FOSElasticaBundle#basic-configuration

fos_elastica:
    clients:
        default: { host: localhost, port: 9200 }

But when it comes to a cluster, I've tried to configure in some ways but it does not work, like this:

fos_elastica:
    clients:
        default: [{host: localhost, port: 9200},{host: localhost, port: 9201}]

And this:

fos_elastica:
    clients:
        default:
            - { host: localhost, port: 9200 }
            - { host: localhost, port: 9201 }

I know that FOSElasticaBundle uses the Elastica library, and that library connects to clusters using arrays of parameters, that is why I have tried those approaches above.

Does anyone know how to connect to configure FOSElasticaBundle to connect to some cluster?

Thanks in advance.

Was it helpful?

Solution

you don't really need to list all your nodes, as ElasticSearch does load balance the cluster. However, it's still possible to do (e.g. in case the node you connect to goes offline). Keep in mind that it's just simple round robin though.

This is how you do it:

fos_elastica:
    clients:
        default:
            servers: 
                - { host: localhost, port: 9200 }
                - { host: localhost, port: 9201 }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top