diff --git a/tests/Tests/Search/Search/SearchApiTests.cs b/tests/Tests/Search/Search/SearchApiTests.cs index 40cdee59a9e..cabe1f82a47 100644 --- a/tests/Tests/Search/Search/SearchApiTests.cs +++ b/tests/Tests/Search/Search/SearchApiTests.cs @@ -721,10 +721,22 @@ public SearchApiRuntimeFieldsTests(ReadOnlyCluster cluster, EndpointUsage usage) protected override void ExpectResponse(ISearchResponse response) { response.Hits.Count.Should().BeGreaterThan(0); - response.Hits.First().Should().NotBeNull(); - response.Hits.First().Fields.ValueOf(p => p.StartedOnDayOfWeek).Should().NotBeNullOrEmpty(); - response.Hits.First().Fields.ValueOf(p => p.ThirtyDaysFromStarted).Should().NotBeNullOrEmpty(); - response.Hits.First().Fields[RuntimeFieldName].As().FirstOrDefault().Should().NotBeNullOrEmpty(); + + foreach (var hit in response.Hits) + { + hit.Should().NotBeNull(); + + if (hit.Source.StartedOn != default) + { + hit.Fields.ValueOf(p => p.StartedOnDayOfWeek).Should().NotBeNullOrEmpty(); + hit.Fields.ValueOf(p => p.ThirtyDaysFromStarted).Should().NotBeNullOrEmpty(); + } + + if (!string.IsNullOrEmpty(hit.Source.Type)) + { + hit.Fields[RuntimeFieldName].As().FirstOrDefault().Should().NotBeNullOrEmpty(); + } + } } } }