Пример #1
0
        public async Task GetAggregations()
        {
            var employees = EmployeeGenerator.GenerateEmployees();
            await _employeeRepository.AddAsync(employees);

            await _client.RefreshAsync();

            var result = await _employeeRepository.CountBySearchAsync(null, null, "terms:Id");

            Assert.Equal(10, result.Total);
        }
        public async Task CanGetGeoGridAggregationAsync()
        {
            var utcNow   = SystemClock.UtcNow;
            var employee = await _employeeRepository.AddAsync(EmployeeGenerator.Generate(ObjectId.GenerateNewId().ToString(), createdUtc: utcNow.AddDays(-1)), o => o.ImmediateConsistency());

            Assert.NotNull(employee?.Id);
            await _employeeRepository.AddAsync(EmployeeGenerator.GenerateEmployees(), o => o.ImmediateConsistency());

            var result = await _employeeRepository.CountBySearchAsync(null, aggregations : "geogrid:(location~6 max:age)");

            Assert.Equal(1, result.Aggregations.Count);
            var geoAgg = result.Aggregations.GeoHash("geogrid_location");

            Assert.NotNull(geoAgg);
            Assert.InRange(geoAgg.Buckets.Count, 1, 11);
        }
Пример #3
0
        public async Task CanGetGeoGridAggregation()
        {
            var utcNow   = SystemClock.UtcNow;
            var employee = await _employeeRepository.AddAsync(EmployeeGenerator.Generate(ObjectId.GenerateNewId().ToString(), createdUtc: utcNow.AddDays(-1)));

            Assert.NotNull(employee?.Id);
            await _employeeRepository.AddAsync(EmployeeGenerator.GenerateEmployees());

            await _client.RefreshAsync();

            var result = await _employeeRepository.CountBySearchAsync(null, aggregations : "geogrid:(location~6 max:age)");

            Assert.Equal(1, result.Aggregations.Count);
            var geoAgg = result.Aggregations.FirstOrDefault(a => a.Key == "geogrid_location");

            Assert.NotNull(geoAgg);
            Assert.InRange(geoAgg.Value.Buckets.Count, 1, 11);
        }