public async Task ClusterSettingsAsync()
        {
            if (TestConfiguration.Instance.InRange("<6.1.0"))
            {
                return;
            }

            var clusterConfiguration = new Dictionary <string, object>()
            {
                { "cluster.routing.use_adaptive_replica_selection", true }
            };

            if (TestConfiguration.Instance.InRange(">=6.5.0"))
            {
                clusterConfiguration += new RemoteClusterConfiguration
                {
                    { RemoteClusterName, "127.0.0.1:9300" }
                }
            }
            ;

            var putSettingsResponse = await Client.Cluster.PutSettingsAsync(new ClusterPutSettingsRequest
            {
                Transient = clusterConfiguration
            }).ConfigureAwait(false);

            putSettingsResponse.ShouldBeValid();
        }
Beispiel #2
0
        protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values)
        {
            var oldWay = new M
            {
                {
                    "search", new M
                    {
                        {
                            "remote", new M
                            {
                                {
                                    "cluster_one", new M
                                    {
                                        { "seeds", new[] { "127.0.0.1:9300", "127.0.0.1:9301" } }
                                    }
                                },
                                {
                                    "cluster_two", new M
                                    {
                                        { "seeds", new[] { "127.0.0.1:9300" } }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            /**
             * As of 6.5.0 you can also use the following helper class which uses
             * the new way to configure remote clusters.
             */
            // ReSharper disable once UnusedVariable
            var newWay = new RemoteClusterConfiguration()
            {
                { "cluster_one", "127.0.0.1:9300", "127.0.0.1:9301" },
                { "cluster_two", "127.0.0.1:9300" }
            };
            var enableRemoteClusters = client.Cluster.PutSettings(new ClusterPutSettingsRequest
            {
                Transient = oldWay
            });

            enableRemoteClusters.ShouldBeValid();

            var remoteSearch = client.Search <Project>(s => s.Index(Index <Project>("cluster_one").And <Project>("cluster_two")));

            remoteSearch.ShouldBeValid();
        }