protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var max = response.Aggs.Max("max_commits"); max.Should().NotBeNull(); max.Value.Should().BeGreaterThan(0); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var projectCount = response.Aggs.Cardinality("state_count"); projectCount.Should().NotBeNull(); projectCount.Value.Should().Be(3); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var sumTheHardWay = response.Aggs.ScriptedMetric("sum_the_hard_way"); sumTheHardWay.Should().NotBeNull(); sumTheHardWay.Value<int>().Should().BeGreaterThan(0); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var sigNames = response.Aggs.SignificantTerms("significant_names"); sigNames.Should().NotBeNull(); sigNames.DocCount.Should().BeGreaterThan(0); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var min = response.Aggs.Min("min_last_activity"); min.Should().NotBeNull(); min.Value.Should().BeGreaterThan(0); min.ValueAsString.Should().NotBeNullOrEmpty(); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var allProjects = response.Aggs.Global("all_projects"); allProjects.Should().NotBeNull(); var names = allProjects.Terms("names"); names.Should().NotBeNull(); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var sample = response.Aggs.Sampler("sample"); sample.Should().NotBeNull(); var sigTags = sample.SignificantTerms("significant_names"); sigTags.Should().NotBeNull(); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var commitsOutlier = response.Aggs.PercentileRanks("commits_outlier"); commitsOutlier.Should().NotBeNull(); commitsOutlier.Items.Should().NotBeNullOrEmpty(); foreach (var item in commitsOutlier.Items) item.Should().NotBeNull(); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var commitsAvg = response.Aggs.Average("average_commits"); commitsAvg.Should().NotBeNull(); commitsAvg.Value.Should().BeGreaterThan(0); commitsAvg.Meta.Should().NotBeNull().And.HaveCount(1); commitsAvg.Meta["foo"].Should().Be("bar"); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var commitRanges = response.Aggs.Range("commit_ranges"); commitRanges.Should().NotBeNull(); commitRanges.Buckets.Count.Should().Be(3); commitRanges.Buckets.Where(r => r.Key == "*-100.0").FirstOrDefault().Should().NotBeNull(); commitRanges.Buckets.Where(r => r.Key == "100.0-500.0").FirstOrDefault().Should().NotBeNull(); commitRanges.Buckets.Where(r => r.Key == "500.0-*").FirstOrDefault().Should().NotBeNull(); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var commits = response.Aggs.Histogram("commits"); commits.Should().NotBeNull(); commits.Buckets.Should().NotBeNull(); commits.Buckets.Count.Should().BeGreaterThan(0); foreach (var item in commits.Buckets) item.DocCount.Should().BeGreaterThan(0); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var matrix = response.Aggs.MatrixStats("matrixstats"); matrix.Should().NotBeNull(); matrix.Fields.Should().NotBeNull().And.HaveCount(2); AssertField(matrix, "numberOfCommits"); AssertField(matrix, "numberOfContributors"); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var commitStats = response.Aggs.Stats("commit_stats"); commitStats.Should().NotBeNull(); commitStats.Average.Should().BeGreaterThan(0); commitStats.Max.Should().BeGreaterThan(0); commitStats.Min.Should().BeGreaterThan(0); commitStats.Count.Should().BeGreaterThan(0); commitStats.Sum.Should().BeGreaterThan(0); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); foreach (var document in response.Documents) { document.Name.Should().NotBeNull(); document.StartedOn.Should().NotBe(default(DateTime)); document.Description.Should().BeNull(); } }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); var averageCommits = response.Aggs.AverageBucket("average_commits_per_month"); averageCommits.Should().NotBeNull(); averageCommits.Value.Should().BeGreaterThan(0); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var tags = response.Aggs.Nested("tags"); tags.Should().NotBeNull(); var tagNames = tags.Terms("tag_names"); tagNames.Should().NotBeNull(); foreach(var item in tagNames.Buckets) { item.Key.Should().NotBeNullOrEmpty(); item.DocCount.Should().BeGreaterThan(0); } }
protected override void ExpectResponse(ISearchResponse<Project> response) { /** === Handling Responses * Using the `.Aggs` aggregation helper we can fetch our aggregation results easily * in the correct type. <<aggs-vs-aggregations, Be sure to read more about .Aggs vs .Aggregations>> */ response.ShouldBeValid(); var filterAgg = response.Aggs.Filter("bethels_projects"); filterAgg.Should().NotBeNull(); filterAgg.DocCount.Should().BeGreaterThan(0); var tags = filterAgg.Terms("project_tags"); tags.Should().NotBeNull(); tags.Buckets.Should().NotBeEmpty(); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); var commitsOutlier = response.Aggs.PercentilesBucket("commits_outlier"); commitsOutlier.Should().NotBeNull(); commitsOutlier.Items.Should().NotBeNullOrEmpty(); foreach (var item in commitsOutlier.Items) item.Value.Should().BeGreaterThan(0); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); foreach (var item in projectsPerMonth.Buckets) { var commits = item.Sum("commits"); commits.Should().NotBeNull(); commits.Value.Should().NotBe(null); } }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var commitStats = response.Aggs.ExtendedStats("commit_stats"); commitStats.Should().NotBeNull(); commitStats.Average.Should().BeGreaterThan(0); commitStats.Max.Should().BeGreaterThan(0); commitStats.Min.Should().BeGreaterThan(0); commitStats.Count.Should().BeGreaterThan(0); commitStats.Sum.Should().BeGreaterThan(0); commitStats.SumOfSquares.Should().BeGreaterThan(0); commitStats.StdDeviation.Should().BeGreaterThan(0); commitStats.StdDeviationBounds.Should().NotBeNull(); commitStats.StdDeviationBounds.Upper.Should().BeGreaterThan(0); commitStats.StdDeviationBounds.Lower.Should().NotBe(0); }
protected override void ExpectResponse(ISearchResponse <Project> response) { /** === Handling Responses * Using the `.Aggs` aggregation helper we can fetch our aggregation results easily * in the correct type. <<aggs-vs-aggregations, Be sure to read more about .Aggs vs .Aggregations>> */ response.ShouldBeValid(); var filterAgg = response.Aggs.Filter("bethels_projects"); filterAgg.Should().NotBeNull(); filterAgg.DocCount.Should().BeGreaterThan(0); var tags = filterAgg.Terms("project_tags"); tags.Should().NotBeNull(); tags.Buckets.Should().NotBeEmpty(); }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggregations.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); foreach (var item in projectsPerMonth.Buckets) { var stablePercentage = item.BucketScript("stable_percentage"); stablePercentage.Should().NotBeNull(); stablePercentage.Value.Should().HaveValue(); } }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var projects = response.Aggregations.Terms("projects"); foreach (var bucket in projects.Buckets) { var centroid = bucket.GeoCentroid("centroid"); centroid.Should().NotBeNull(); centroid.Count.Should().BeGreaterThan(0); centroid.Location.Should().NotBeNull(); centroid.Location.Latitude.Should().NotBe(0); centroid.Location.Longitude.Should().NotBe(0); } }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var commits = response.Aggs.Terms <int>("commits"); commits.Should().NotBeNull(); commits.DocCountErrorUpperBound.Should().HaveValue(); commits.SumOtherDocCount.Should().HaveValue(); commits.Buckets.Should().NotBeNull(); commits.Buckets.Count.Should().BeGreaterThan(0); foreach (var item in commits.Buckets) { item.Key.Should().BeGreaterThan(0); item.DocCount.Should().BeGreaterOrEqualTo(1); } commits.Buckets.Should().Contain(b => b.DocCountErrorUpperBound.HasValue); }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggregations.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); foreach (var bucket in projectsPerMonth.Buckets) { var normalize = bucket.Normalize("percent_of_commits"); normalize.Value.Should().BeGreaterOrEqualTo(0); normalize.ValueAsString.Should().NotBeNullOrEmpty(); } }
#pragma warning restore 618 protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggregations.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); foreach (var item in projectsPerMonth.Buckets) { var commitsDerivative = item.CumulativeSum("cumulative_commits"); commitsDerivative.Should().NotBeNull(); commitsDerivative.Value.Should().NotBe(null); } }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var commitStats = response.Aggregations.ExtendedStats("commit_stats"); commitStats.Should().NotBeNull(); commitStats.Average.Should().BeGreaterThan(0); commitStats.Max.Should().BeGreaterThan(0); commitStats.Min.Should().BeGreaterThan(0); commitStats.Count.Should().BeGreaterThan(0); commitStats.Sum.Should().BeGreaterThan(0); commitStats.SumOfSquares.Should().BeGreaterThan(0); commitStats.StdDeviation.Should().BeGreaterThan(0); commitStats.StdDeviationBounds.Should().NotBeNull(); commitStats.StdDeviationBounds.Upper.Should().BeGreaterThan(0); commitStats.StdDeviationBounds.Lower.Should().NotBe(0); }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); foreach (var item in projectsPerMonth.Buckets) { var commits = item.Sum("commits"); commits.Should().NotBeNull(); commits.Value.Should().BeGreaterOrEqualTo(500); } }
#pragma warning restore 618, 612 protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggregations.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); // average not calculated for the first bucket foreach (var item in projectsPerMonth.Buckets.Skip(1)) { var movingAvg = item.MovingAverage("commits_moving_avg"); movingAvg.Should().NotBeNull(); movingAvg.Value.Should().BeGreaterThan(0); } }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggregations.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); // percentiles not calculated for the first bucket foreach (var item in projectsPerMonth.Buckets.Skip(1)) { var movingPercentiles = item.MovingPercentiles("moving_percentiles"); movingPercentiles.Should().NotBeNull(); movingPercentiles.Items.Should().NotBeNull(); } }
protected override void ExpectResponse(ISearchResponse <Project> response) { /** ==== Handling Responses * The `AggregateDictionary found on `.Aggregations` on `SearchResponse<T>` has several helper methods * so we can fetch our aggregation results easily in the correct type. * <<handling-aggregate-response, Be sure to read more about these helper methods>> */ response.ShouldBeValid(); var filterAgg = response.Aggregations.Filter("bethels_projects"); filterAgg.Should().NotBeNull(); filterAgg.DocCount.Should().BeGreaterThan(0); var tags = filterAgg.Terms("project_tags"); tags.Should().NotBeNull(); tags.Buckets.Should().NotBeEmpty(); }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var ipRanges = response.Aggregations.IpRange("ip_ranges"); ipRanges.Should().NotBeNull(); ipRanges.Buckets.Should().NotBeNull(); ipRanges.Buckets.Count.Should().BeGreaterThan(0); foreach (var range in ipRanges.Buckets) { if (TestConfiguration.Instance.InRange("6.4.0")) { range.Key.Should().NotBeNullOrEmpty(); } range.DocCount.Should().BeGreaterThan(0); } }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var states = response.Aggs.Terms("states"); states.Should().NotBeNull(); states.DocCountErrorUpperBound.Should().HaveValue(); states.SumOtherDocCount.Should().HaveValue(); states.Buckets.Should().NotBeNull(); states.Buckets.Count.Should().BeGreaterThan(0); foreach (var item in states.Buckets) { item.Key.Should().NotBeNullOrEmpty(); item.DocCount.Should().BeGreaterOrEqualTo(1); } states.Meta.Should().NotBeNull().And.HaveCount(1); states.Meta["foo"].Should().Be("bar"); }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggregations.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); // derivative not calculated for the first bucket foreach (var item in projectsPerMonth.Buckets.Skip(1)) { var commitsDerivative = item.Derivative("commits_derivative"); commitsDerivative.Should().NotBeNull(); commitsDerivative.Value.Should().NotBe(null); } }
protected override void ExpectResponse(ISearchResponse <Project> response) { /** ==== Handling responses * The `AggregateDictionary found on `.Aggregations` on `ISearchResponse<T>` has several helper methods * so we can fetch our aggregation results easily in the correct type. * <<handling-aggregate-response, Be sure to read more about these helper methods>> */ response.ShouldBeValid(); var dateHistogram = response.Aggregations.AutoDateHistogram("projects_started_per_month"); dateHistogram.Should().NotBeNull(); dateHistogram.Interval.Should().NotBeNull(); dateHistogram.Buckets.Should().NotBeNull(); dateHistogram.Buckets.Count.Should().BeGreaterThan(1); foreach (var item in dateHistogram.Buckets) { item.Date.Should().NotBe(default);
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); var commitsOutlier = response.Aggs.PercentilesBucket("commits_outlier"); commitsOutlier.Should().NotBeNull(); commitsOutlier.Items.Should().NotBeNullOrEmpty(); foreach (var item in commitsOutlier.Items) { item.Value.Should().BeGreaterThan(0); } }
#pragma warning restore 618, 612 protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggregations.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); var commitsStats = response.Aggregations.StatsBucket("stats_commits_per_month"); commitsStats.Should().NotBeNull(); commitsStats.Average.Should().BeGreaterThan(0); commitsStats.Max.Should().BeGreaterThan(0); commitsStats.Min.Should().BeGreaterThan(0); commitsStats.Count.Should().BeGreaterThan(0); commitsStats.Sum.Should().BeGreaterThan(0); }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var composite = response.Aggregations.Composite("my_buckets"); composite.Should().NotBeNull(); composite.Buckets.Should().NotBeNullOrEmpty(); composite.AfterKey.Should().NotBeNull(); composite.AfterKey.Should().HaveCount(1).And.ContainKeys("started"); foreach (var item in composite.Buckets) { var key = item.Key; key.Should().NotBeNull(); key.TryGetValue("started", out string startedString).Should().BeTrue(); startedString.Should().NotBeNullOrWhiteSpace(); } }
protected override void ExpectResponse(ISearchResponse <Project> response) { /** === Handling Responses * Using the `.Agg` aggregation helper we can fetch our aggregation results easily * in the correct type. <<aggs-vs-aggregations, Be sure to read more about .Aggs vs .Aggregations>> */ response.ShouldBeValid(); var dateHistogram = response.Aggs.DateRange("projects_date_ranges"); dateHistogram.Should().NotBeNull(); dateHistogram.Buckets.Should().NotBeNull(); /** We specified three ranges so we expect to have three of them in the response */ dateHistogram.Buckets.Count.Should().Be(3); foreach (var item in dateHistogram.Buckets) { item.DocCount.Should().BeGreaterThan(0); } }
/**==== Handling Responses * Each Composite aggregation bucket key is a `CompositeKey` type, a specialized * `IReadOnlyDictionary<string, object>` type with methods to convert values to supported types */ protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var composite = response.Aggregations.Composite("my_buckets"); composite.Should().NotBeNull(); composite.Buckets.Should().NotBeNullOrEmpty(); composite.AfterKey.Should().NotBeNull(); if (TestConfiguration.Instance.InRange(">=6.3.0")) { composite.AfterKey.Should() .HaveCount(3) .And.ContainKeys("branches", "started", "branch_count"); } foreach (var item in composite.Buckets) { var key = item.Key; key.Should().NotBeNull(); key.TryGetValue("branches", out string branches).Should().BeTrue(); branches.Should().NotBeNullOrEmpty(); key.TryGetValue("started", out DateTime started).Should().BeTrue(); started.Should().BeAfter(default(DateTime)); key.TryGetValue("branch_count", out int branchCount).Should().BeTrue(); branchCount.Should().BeGreaterThan(0); item.DocCount.Should().BeGreaterThan(0); var nested = item.Nested("project_tags"); nested.Should().NotBeNull(); if (nested.DocCount > 0) { var nestedTerms = nested.Terms("tags"); nestedTerms.Buckets.Count.Should().BeGreaterThan(0); } } }
#pragma warning restore 618, 612 protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggregations.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); var maxCommits = response.Aggregations.MaxBucket("max_commits_per_month"); maxCommits.Should().NotBeNull(); maxCommits.Value.Should().BeGreaterThan(0); maxCommits.Keys.Should().NotBeNull(); maxCommits.Keys.Count.Should().BeGreaterOrEqualTo(1); foreach (var key in maxCommits.Keys) { key.Should().NotBeNull(); } }
protected override void ExpectResponse(ISearchResponse <Project> response) { /** ==== Handling Responses * The `AggregateDictionary found on `.Aggregations` on `SearchResponse<T>` has several helper methods * so we can fetch our aggregation results easily in the correct type. * <<handling-aggregate-response, Be sure to read more about these helper methods>> */ response.ShouldBeValid(); var dateHistogram = response.Aggregations.DateRange("projects_date_ranges"); dateHistogram.Should().NotBeNull(); dateHistogram.Buckets.Should().NotBeNull(); /** We specified three ranges so we expect to have three of them in the response */ dateHistogram.Buckets.Count.Should().Be(3); foreach (var item in dateHistogram.Buckets) { item.DocCount.Should().BeGreaterThan(0); } }
/**==== Handling Responses * Each Composite aggregation bucket key is an `CompositeKey`, a specialized * `IReadOnlyDictionary<string, object>` type with methods to convert values to supported types */ protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var composite = response.Aggregations.Composite("my_buckets"); composite.Should().NotBeNull(); composite.Buckets.Should().NotBeNullOrEmpty(); composite.AfterKey.Should().NotBeNull(); if (TestConfiguration.Instance.InRange(">=6.3.0")) { composite.AfterKey.Should().HaveCount(1).And.ContainKeys("branches"); } var i = 0; foreach (var item in composite.Buckets) { var key = item.Key; key.Should().NotBeNull(); key.TryGetValue("branches", out string branches).Should().BeTrue("expected to find 'branches' in composite bucket"); if (i == 0) { branches.Should().BeNull("First key should be null as we expect to have some projects with no branches"); } else { branches.Should().NotBeNullOrEmpty(); } var nested = item.Nested("project_tags"); nested.Should().NotBeNull(); var nestedTerms = nested.Terms("tags"); nestedTerms.Buckets.Count.Should().BeGreaterThan(0); i++; } }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); foreach (var highlightsByDocumentId in response.Highlights) { foreach (var highlightHit in highlightsByDocumentId.Value) { if (highlightHit.Key == "name.standard") { foreach (var highlight in highlightHit.Value.Highlights) { highlight.Should().Contain("<tag1>"); highlight.Should().Contain("</tag1>"); } } else if (highlightHit.Key == "leadDeveloper.firstName") { foreach (var highlight in highlightHit.Value.Highlights) { highlight.Should().Contain("<name>"); highlight.Should().Contain("</name>"); } } else if (highlightHit.Key == "state.offsets") { foreach (var highlight in highlightHit.Value.Highlights) { highlight.Should().Contain("<state>"); highlight.Should().Contain("</state>"); } } else { Assert.True(false, $"highlights contains unexpected key {highlightHit.Key}"); } } } }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); foreach (var highlightsInEachHit in response.Hits.Select(d => d.Highlight)) { foreach (var highlightField in highlightsInEachHit) { if (highlightField.Key == "name.standard") { foreach (var highlight in highlightField.Value) { highlight.Should().Contain("<tag1>"); highlight.Should().Contain("</tag1>"); } } else if (highlightField.Key == "leadDeveloper.firstName") { foreach (var highlight in highlightField.Value) { highlight.Should().Contain("<name>"); highlight.Should().Contain("</name>"); } } else if (highlightField.Key == "leadDeveloper.lastName") { foreach (var highlight in highlightField.Value) { highlight.Should().Contain("<name>"); highlight.Should().Contain("</name>"); } } else { Assert.True(false, $"highlights contains unexpected key {highlightField.Key}"); } } } }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); var commitsStats = response.Aggs.ExtendedStatsBucket("extended_stats_commits_per_month"); commitsStats.Should().NotBeNull(); commitsStats.Average.Should().BeGreaterThan(0); commitsStats.Max.Should().BeGreaterThan(0); commitsStats.Min.Should().BeGreaterThan(0); commitsStats.Count.Should().BeGreaterThan(0); commitsStats.Sum.Should().BeGreaterThan(0); commitsStats.SumOfSquares.Should().BeGreaterThan(0); commitsStats.StdDeviation.Should().BeGreaterThan(0); commitsStats.StdDeviationBounds.Should().NotBeNull(); commitsStats.StdDeviationBounds.Upper.Should().BeGreaterThan(0); commitsStats.StdDeviationBounds.Lower.Should().NotBe(0); }
protected override void ExpectResponse(ISearchResponse <Project> response) { /** === Handling Responses * Using the `.Agg` aggregation helper we can fetch our aggregation results easily * in the correct type. <<aggs-vs-aggregations, Be sure to read more about .Aggs vs .Aggregations>> */ response.ShouldBeValid(); var filterAgg = response.Aggs.Filters("projects_by_state"); filterAgg.Should().NotBeNull(); var results = filterAgg.AnonymousBuckets(); results.Count.Should().Be(4); foreach (var singleBucket in results.Take(3)) { singleBucket.DocCount.Should().BeGreaterThan(0); } results.Last().DocCount.Should().Be(0); // <1> The last bucket is the _other bucket_ }
protected override void ExpectResponse(ISearchResponse <Project> response) { /** ==== Handling Responses * The `AggregateDictionary found on `.Aggregations` on `SearchResponse<T>` has several helper methods * so we can fetch our aggregation results easily in the correct type. * <<handling-aggregate-response, Be sure to read more about these helper methods>> */ response.ShouldBeValid(); var filterAgg = response.Aggregations.Filters("projects_by_state"); filterAgg.Should().NotBeNull(); var results = filterAgg.AnonymousBuckets(); results.Count.Should().Be(4); foreach (var singleBucket in results.Take(3)) { singleBucket.DocCount.Should().BeGreaterThan(0); } results.Last().DocCount.Should().Be(0); // <1> The last bucket is the _other bucket_ }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var tags = response.Aggregations.Nested("tags"); tags.Should().NotBeNull(); var tagNames = tags.Terms("tag_names"); tagNames.Should().NotBeNull(); foreach (var tagName in tagNames.Buckets) { tagName.Key.Should().NotBeNullOrEmpty(); tagName.DocCount.Should().BeGreaterThan(0); var tagsToProjects = tagName.ReverseNested("tags_to_project"); tagsToProjects.Should().NotBeNull(); var topProjectsPerTag = tagsToProjects.Terms("top_projects_per_tag"); topProjectsPerTag.Should().NotBeNull(); foreach (var topProject in topProjectsPerTag.Buckets) { topProject.Key.Should().NotBeNullOrEmpty(); topProject.DocCount.Should().BeGreaterThan(0); } } }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var viewport = response.Aggregations.GeoBounds("viewport"); viewport.Should().NotBeNull(); viewport.Bounds.Should().NotBeNull(); var bottomRight = viewport.Bounds.BottomRight; bottomRight.Should().NotBeNull(); bottomRight.Lat.Should().HaveValue(); GeoLocation.IsValidLatitude(bottomRight.Lat.Value).Should().BeTrue(); bottomRight.Lon.Should().HaveValue(); GeoLocation.IsValidLongitude(bottomRight.Lon.Value).Should().BeTrue(); var topLeft = viewport.Bounds.TopLeft; topLeft.Should().NotBeNull(); topLeft.Lat.Should().HaveValue(); GeoLocation.IsValidLatitude(topLeft.Lat.Value).Should().BeTrue(); topLeft.Lon.Should().HaveValue(); GeoLocation.IsValidLongitude(topLeft.Lon.Value).Should().BeTrue(); }
protected override void ExpectResponse(ISearchResponse <Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); var commitsStats = response.Aggs.ExtendedStatsBucket("extended_stats_commits_per_month"); commitsStats.Should().NotBeNull(); commitsStats.Average.Should().BeGreaterThan(0); commitsStats.Max.Should().BeGreaterThan(0); commitsStats.Min.Should().BeGreaterThan(0); commitsStats.Count.Should().BeGreaterThan(0); commitsStats.Sum.Should().BeGreaterThan(0); commitsStats.SumOfSquares.Should().BeGreaterThan(0); commitsStats.StdDeviation.Should().BeGreaterThan(0); commitsStats.StdDeviationBounds.Should().NotBeNull(); commitsStats.StdDeviationBounds.Upper.Should().BeGreaterThan(0); commitsStats.StdDeviationBounds.Lower.Should().NotBe(0); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var tags = response.Aggs.Nested("tags"); tags.Should().NotBeNull(); var tagNames = tags.Terms("tag_names"); tagNames.Should().NotBeNull(); foreach(var tagName in tagNames.Buckets) { tagName.Key.Should().NotBeNullOrEmpty(); tagName.DocCount.Should().BeGreaterThan(0); var tagsToProjects = tagName.ReverseNested("tags_to_project"); tagsToProjects.Should().NotBeNull(); var topProjectsPerTag = tagsToProjects.Terms("top_projects_per_tag"); topProjectsPerTag.Should().NotBeNull(); foreach(var topProject in topProjectsPerTag.Buckets) { topProject.Key.Should().NotBeNullOrEmpty(); topProject.DocCount.Should().BeGreaterThan(0); } } }
protected override void ExpectResponse(ISearchResponse<Project> response) { /** === Handling Responses * Using the `.Agg` aggregation helper we can fetch our aggregation results easily * in the correct type. <<aggs-vs-aggregations, Be sure to read more about .Aggs vs .Aggregations>> */ response.ShouldBeValid(); var dateHistogram = response.Aggs.DateRange("projects_date_ranges"); dateHistogram.Should().NotBeNull(); dateHistogram.Buckets.Should().NotBeNull(); /** We specified three ranges so we expect to have three of them in the response */ dateHistogram.Buckets.Count.Should().Be(3); foreach (var item in dateHistogram.Buckets) { item.DocCount.Should().BeGreaterThan(0); } }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); }
protected override void ExpectResponse(ISearchResponse<Project> response) { /** === Handling responses * Using the `.Aggs` aggregation helper on `ISearchResponse<T>`, we can fetch our aggregation results easily * in the correct type. <<aggs-vs-aggregations, Be sure to read more about .Aggs vs .Aggregations>> */ response.ShouldBeValid(); var dateHistogram = response.Aggs.DateHistogram("projects_started_per_month"); dateHistogram.Should().NotBeNull(); dateHistogram.Buckets.Should().NotBeNull(); dateHistogram.Buckets.Count.Should().BeGreaterThan(10); dateHistogram.Buckets.Should().NotBeNull(); dateHistogram.Buckets.Count.Should().BeGreaterThan(0); foreach (var item in dateHistogram.Buckets) { item.Date.Should().NotBe(default(DateTime)); item.DocCount.Should().BeGreaterThan(0); var nested = item.Nested("project_tags"); nested.Should().NotBeNull(); var nestedTerms = nested.Terms("tags"); nestedTerms.Buckets.Count.Should().BeGreaterThan(0); } }
protected override void ExpectResponse(ISearchResponse<Project> response) { /** === Handling Responses * Using the `.Agg` aggregation helper we can fetch our aggregation results easily * in the correct type. <<aggs-vs-aggregations, Be sure to read more about .Aggs vs .Aggregations>> */ response.ShouldBeValid(); var filterAgg = response.Aggs.Filters("projects_by_state"); filterAgg.Should().NotBeNull(); var results = filterAgg.AnonymousBuckets(); results.Count.Should().Be(4); foreach (var singleBucket in results.Take(3)) { singleBucket.DocCount.Should().BeGreaterThan(0); } results.Last().DocCount.Should().Be(0); // <1> The last bucket is the _other bucket_ }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var myGeoHashGrid = response.Aggs.GeoHash("my_geohash_grid"); myGeoHashGrid.Should().NotBeNull(); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); var projectsPerMonth = response.Aggs.DateHistogram("projects_started_per_month"); projectsPerMonth.Should().NotBeNull(); projectsPerMonth.Buckets.Should().NotBeNull(); projectsPerMonth.Buckets.Count.Should().BeGreaterThan(0); // average not calculated for the first bucket foreach(var item in projectsPerMonth.Buckets.Skip(1)) { var movingAvg = item.MovingAverage("commits_moving_avg"); movingAvg.Should().NotBeNull(); movingAvg.Value.Should().BeGreaterThan(0); } }
protected override void ExpectResponse(ISearchResponse<Project> response) { /** === Handling Responses * Using the `.Agg` aggregation helper we can fetch our aggregation results easily * in the correct type. <<aggs-vs-aggregations, Be sure to read more about .Aggs vs .Aggregations>> */ response.ShouldBeValid(); var filterAgg = response.Aggs.Filters("projects_by_state"); filterAgg.Should().NotBeNull(); var namedResult = filterAgg.NamedBucket("belly_up"); namedResult.Should().NotBeNull(); namedResult.DocCount.Should().BeGreaterThan(0); namedResult = filterAgg.NamedBucket("stable"); namedResult.Should().NotBeNull(); namedResult.DocCount.Should().BeGreaterThan(0); namedResult = filterAgg.NamedBucket("very_active"); namedResult.Should().NotBeNull(); namedResult.DocCount.Should().BeGreaterThan(0); namedResult = filterAgg.NamedBucket("other_states_of_being"); namedResult.Should().NotBeNull(); namedResult.DocCount.Should().Be(0); }
protected override void ExpectResponse(ISearchResponse<Project> response) { response.ShouldBeValid(); response.Aggs.Filters("conditionless_filters").Buckets.Should().BeEmpty(); }