public async Task ShouldAggregateWithoutAggregators() { // Todo: does not find anything // Check: does Aggregate() without Aggregators make any sense? //// TODO: Must be extended and asserted with useful data. var request = new ContentAggregationRequest() { SearchString = "*" }; ObjectAggregationResult result = await _client.Contents.AggregateAsync(request); var numRangeFilter = new NumericRangeFilter() { Field = "ContentType", Range = new NumericRange { From = 2, To = 5 } }; request.Filter = numRangeFilter; result = await _client.Contents.AggregateAsync(request); request.Filter = null; request.LifeCycleFilter = LifeCycleFilter.All; result = await _client.Contents.AggregateAsync(request); request.Aggregators = new List <AggregatorBase>(); result = await _client.Contents.AggregateAsync(request); }
public async Task ShouldAggregateObjects() { // Arrange var fieldName = nameof(Country).ToLowerCamelCase() + "." + nameof(Country.RegionCode).ToLowerCamelCase(); var request = new ListItemAggregationRequest { SearchString = "*", SchemaIds = new List <string> { nameof(Country) }, Aggregators = new List <AggregatorBase> { new TermsAggregator { Name = fieldName, Field = fieldName, Size = 20 } } }; // Act ObjectAggregationResult result = await _client.ListItem.AggregateAsync(request).ConfigureAwait(false); AggregationResult aggregation = result.GetByName(fieldName); // Assert Assert.NotNull(aggregation); Assert.Equal(20, aggregation.AggregationResultItems.Count); }
public async Task ShouldAggregateWithAggregators() { var request = new ContentAggregationRequest { SearchString = string.Empty, Aggregators = new List <AggregatorBase> { new TermsAggregator { Name = "Aggregator1", Field = "contentType", Size = 10 } } }; // Second Aggregator var ranges = new List <NumericRange> { new NumericRange { From = null, To = 499, Names = new TranslatedStringDictionary { { "en", "Aggregator2a" } } }, new NumericRange { From = 500, To = 5000, Names = new TranslatedStringDictionary { { "en", "Aggregator2b" } } } }; var numRangeAggregator = new NumericRangeAggregator() { Name = "NumberAggregator", Field = "Original.Width", Ranges = ranges }; request.Aggregators.Add(numRangeAggregator); ObjectAggregationResult result = await _client.Contents.AggregateAsync(request); }