コード例 #1
0
        public HomeController()
        {
            var node = new Uri("http://localhost:9200");
            var connectionSettings = new ConnectionSettings(node).DefaultIndex("elasticsearch-sample");

            _client = new ProfiledElasticClient(connectionSettings);
        }
コード例 #2
0
        public async Task ProfiledElasticClient_IndexDocument_ProfilerIncludesTimings()
        {
            // Arrange
            var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
            var settings       = new ConnectionSettings(connectionPool, new InMemoryConnection())
                                 .DefaultIndex("test-index");

            var profiler = StackExchangeMiniProfiler.StartNew();
            var client   = new ProfiledElasticClient(settings);
            var person   = new { Id = "1" };

            // Act
            await client.IndexDocumentAsync(person);

            // Assert
            var customTimings = profiler.Root.CustomTimings;

            Assert.Single(customTimings);
            Assert.True(customTimings.TryGetValue("elasticsearch", out var elasticTimings));
            Assert.Single(elasticTimings);
        }