Skip to content

Commit 04e7c66

Browse files
codebrainStuart Cam
authored andcommitted
Ignore Empty Filters tests (#3957)
Elasticsearch 7.2.0 introduced a change to empty filters handling in elastic/elasticsearch#41459 (cherry picked from commit a8e502f)
1 parent c6f929a commit 04e7c66

File tree

7 files changed

+185
-96
lines changed

7 files changed

+185
-96
lines changed

docs/aggregations.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ In addition to the buckets themselves, the bucket aggregations also compute and
132132

133133
* <<geo-hash-grid-aggregation-usage,Geo Hash Grid Aggregation Usage>>
134134

135+
* <<geo-tile-grid-aggregation-usage,Geo Tile Grid Aggregation Usage>>
136+
135137
* <<global-aggregation-usage,Global Aggregation Usage>>
136138

137139
* <<histogram-aggregation-usage,Histogram Aggregation Usage>>
@@ -189,6 +191,8 @@ include::aggregations/bucket/geo-distance/geo-distance-aggregation-usage.asciido
189191

190192
include::aggregations/bucket/geo-hash-grid/geo-hash-grid-aggregation-usage.asciidoc[]
191193

194+
include::aggregations/bucket/geo-hash-tile/geo-tile-grid-aggregation-usage.asciidoc[]
195+
192196
include::aggregations/bucket/global/global-aggregation-usage.asciidoc[]
193197

194198
include::aggregations/bucket/histogram/histogram-aggregation-usage.asciidoc[]

docs/aggregations/bucket/filters/filters-aggregation-usage.asciidoc

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -237,94 +237,3 @@ results.Last().DocCount.Should().Be(0); <1>
237237
----
238238
<1> The last bucket is the _other bucket_
239239

240-
[float]
241-
=== Empty Filters
242-
243-
==== Fluent DSL example
244-
245-
[source,csharp]
246-
----
247-
a => a
248-
.Filters("empty_filters", agg => agg
249-
.AnonymousFilters()
250-
)
251-
----
252-
253-
==== Object Initializer syntax example
254-
255-
[source,csharp]
256-
----
257-
new FiltersAggregation("empty_filters")
258-
{
259-
Filters = new List<QueryContainer>()
260-
}
261-
----
262-
263-
[source,javascript]
264-
.Example json output
265-
----
266-
{
267-
"empty_filters": {
268-
"filters": {
269-
"filters": []
270-
}
271-
}
272-
}
273-
----
274-
275-
==== Handling Responses
276-
277-
[source,csharp]
278-
----
279-
response.ShouldBeValid();
280-
response.Aggregations.Filters("empty_filters").Buckets.Should().BeEmpty();
281-
----
282-
283-
[float]
284-
=== Conditionless Filters
285-
286-
==== Fluent DSL example
287-
288-
[source,csharp]
289-
----
290-
a => a
291-
.Filters("conditionless_filters", agg => agg
292-
.AnonymousFilters(
293-
q => new QueryContainer()
294-
)
295-
)
296-
----
297-
298-
==== Object Initializer syntax example
299-
300-
[source,csharp]
301-
----
302-
new FiltersAggregation("conditionless_filters")
303-
{
304-
Filters = new List<QueryContainer>
305-
{
306-
new QueryContainer()
307-
}
308-
}
309-
----
310-
311-
[source,javascript]
312-
.Example json output
313-
----
314-
{
315-
"conditionless_filters": {
316-
"filters": {
317-
"filters": []
318-
}
319-
}
320-
}
321-
----
322-
323-
==== Handling Responses
324-
325-
[source,csharp]
326-
----
327-
response.ShouldBeValid();
328-
response.Aggregations.Filters("conditionless_filters").Buckets.Should().BeEmpty();
329-
----
330-
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/7.0
2+
3+
:github: https://github.com/elastic/elasticsearch-net
4+
5+
:nuget: https://www.nuget.org/packages
6+
7+
////
8+
IMPORTANT NOTE
9+
==============
10+
This file has been generated from https://github.com/elastic/elasticsearch-net/tree/master/src/Tests/Tests/Aggregations/Bucket/GeoHashTile/GeoTileGridAggregationUsageTests.cs.
11+
If you wish to submit a PR for any spelling mistakes, typos or grammatical errors for this file,
12+
please modify the original csharp file found at the link and submit the PR with that change. Thanks!
13+
////
14+
15+
[[geo-tile-grid-aggregation-usage]]
16+
=== Geo Tile Grid Aggregation Usage
17+
18+
==== Fluent DSL example
19+
20+
[source,csharp]
21+
----
22+
a => a
23+
.GeoTile("my_geotile", g => g
24+
.Field(p => p.LocationPoint)
25+
.Precision(GeoTilePrecision.Precision3)
26+
.Size(1000)
27+
.ShardSize(100)
28+
)
29+
----
30+
31+
==== Object Initializer syntax example
32+
33+
[source,csharp]
34+
----
35+
new GeoTileGridAggregation("my_geotile")
36+
{
37+
Field = Field<Project>(p => p.LocationPoint),
38+
Precision = GeoTilePrecision.Precision3,
39+
Size = 1000,
40+
ShardSize = 100
41+
}
42+
----
43+
44+
[source,javascript]
45+
.Example json output
46+
----
47+
{
48+
"my_geotile": {
49+
"geotile_grid": {
50+
"field": "locationPoint",
51+
"precision": 3,
52+
"size": 1000,
53+
"shard_size": 100
54+
}
55+
}
56+
}
57+
----
58+
59+
==== Handling Responses
60+
61+
[source,csharp]
62+
----
63+
response.ShouldBeValid();
64+
var myGeoTileTile = response.Aggregations.GeoTile("my_geotile");
65+
myGeoTileTile.Should().NotBeNull();
66+
myGeoTileTile.Buckets.FirstOrDefault(r => r.Key == "3/0/4").Should().NotBeNull();
67+
myGeoTileTile.Buckets.FirstOrDefault(r => r.Key == "3/5/5").Should().NotBeNull();
68+
----
69+

docs/client-concepts/connection/configuration-options.asciidoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ The following is a list of available connection configuration options on `Connec
2626
`ConnectionSettings` derives from `ConnectionConfiguration`, these options are available for both
2727
the low level and high level client:
2828

29+
`ApiKeyAuthentication`::
30+
31+
Api Key to send with all requests to Elasticsearch
32+
33+
`ApiKeyAuthentication`::
34+
35+
Api Key to send with all requests to Elasticsearch
36+
2937
`BasicAuthentication`::
3038

3139
Basic Authentication credentials to send with all requests to Elasticsearch

docs/mapping/scalar/scalar-usage.asciidoc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ f => f
7373
.Scalar(p => p.DateTimeOffsets, m => m)
7474
.Scalar(p => p.DateTimeOffsetNullable, m => m)
7575
.Scalar(p => p.DateTimeOffsetNullables, m => m)
76+
.ScalarNanos(p => p.DateTimeNanos, m => m)
77+
.ScalarNanos(p => p.DateTimeNanoss, m => m)
78+
.ScalarNanos(p => p.DateTimeNanosNullable, m => m)
79+
.ScalarNanos(p => p.DateTimeNanosNullables, m => m)
80+
.ScalarNanos(p => p.DateTimeNanosOffset, m => m)
81+
.ScalarNanos(p => p.DateTimeNanosOffsets, m => m)
82+
.ScalarNanos(p => p.DateTimeNanosOffsetNullable, m => m)
83+
.ScalarNanos(p => p.DateTimeNanosOffsetNullables, m => m)
7684
.Scalar(p => p.Bool, m => m)
7785
.Scalar(p => p.Bools, m => m)
7886
.Scalar(p => p.BoolNullable, m => m)
@@ -168,6 +176,30 @@ null
168176
"dateTimeOffsetNullables": {
169177
"type": "date"
170178
},
179+
"dateTimeNanos": {
180+
"type": "date_nanos"
181+
},
182+
"dateTimeNanoss": {
183+
"type": "date_nanos"
184+
},
185+
"dateTimeNanosNullable": {
186+
"type": "date_nanos"
187+
},
188+
"dateTimeNanosNullables": {
189+
"type": "date_nanos"
190+
},
191+
"dateTimeNanosOffset": {
192+
"type": "date_nanos"
193+
},
194+
"dateTimeNanosOffsets": {
195+
"type": "date_nanos"
196+
},
197+
"dateTimeNanosOffsetNullable": {
198+
"type": "date_nanos"
199+
},
200+
"dateTimeNanosOffsetNullables": {
201+
"type": "date_nanos"
202+
},
171203
"decimal": {
172204
"type": "double"
173205
},
@@ -359,6 +391,16 @@ public class ScalarPoco
359391
public IEnumerable<DateTimeOffset> DateTimeOffsets { get; set; }
360392
public IEnumerable<DateTime> DateTimes { get; set; }
361393
394+
public DateTime DateTimeNanos { get; set; }
395+
public DateTime? DateTimeNanosNullable { get; set; }
396+
public IEnumerable<DateTime?> DateTimeNanosNullables { get; set; }
397+
398+
public DateTimeOffset DateTimeNanosOffset { get; set; }
399+
public DateTimeOffset? DateTimeNanosOffsetNullable { get; set; }
400+
public IEnumerable<DateTimeOffset?> DateTimeNanosOffsetNullables { get; set; }
401+
public IEnumerable<DateTimeOffset> DateTimeNanosOffsets { get; set; }
402+
public IEnumerable<DateTime> DateTimeNanoss { get; set; }
403+
362404
public decimal Decimal { get; set; }
363405
public decimal? DecimalNullable { get; set; }
364406
public IEnumerable<decimal?> DecimalNullables { get; set; }
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/7.0
2+
3+
:github: https://github.com/elastic/elasticsearch-net
4+
5+
:nuget: https://www.nuget.org/packages
6+
7+
////
8+
IMPORTANT NOTE
9+
==============
10+
This file has been generated from https://github.com/elastic/elasticsearch-net/tree/master/src/Tests/Tests/XPack/Security/ApiKey/SecurityApiKeyUsageTests.cs.
11+
If you wish to submit a PR for any spelling mistakes, typos or grammatical errors for this file,
12+
please modify the original csharp file found at the link and submit the PR with that change. Thanks!
13+
////
14+
15+
[[security-api-key-usage]]
16+
=== Security Api Key Usage
17+
18+
==== Fluent DSL example
19+
20+
[source,csharp]
21+
----
22+
TryGetExtendedValue<CreateApiKeyResponse>("response", out var response);
23+
24+
// Unit tests for HitsTheCorrectUrl will have a null response object.
25+
if (response == null)
26+
return d => d;
27+
28+
return d => d.RequestConfiguration(r => r.ApiKeyAuthentication(response.Id, response.ApiKey));
29+
----
30+
31+
==== Object Initializer syntax example
32+
33+
[source,csharp]
34+
----
35+
TryGetExtendedValue<CreateApiKeyResponse>("response", out var response);
36+
37+
// Unit tests for HitsTheCorrectUrl will have a null response object.
38+
if (response == null)
39+
return new NodesInfoRequest();
40+
41+
return new NodesInfoRequest
42+
{
43+
RequestConfiguration = new RequestConfiguration
44+
{
45+
ApiKeyAuthenticationCredentials = new ApiKeyAuthenticationCredentials(response.Id, response.ApiKey)
46+
}
47+
};
48+
----
49+
50+
==== Handling Responses
51+
52+
[source,csharp]
53+
----
54+
response.IsValid.Should().BeTrue();
55+
response.Nodes.Should().NotBeEmpty();
56+
----
57+

src/Tests/Tests/Aggregations/Bucket/Filters/FiltersAggregationUsageTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using Elastic.Xunit.XunitPlumbing;
45
using FluentAssertions;
56
using Nest;
67
using Tests.Core.Extensions;
@@ -182,9 +183,8 @@ protected override void ExpectResponse(ISearchResponse<Project> response)
182183
}
183184
}
184185

185-
/**[float]
186-
* === Empty Filters
187-
*/
186+
// hide
187+
[SkipVersion(">=7.2.0", "Fixed in 7.2.0 server, FiltersAggregation NPE when filters is empty #41459 (issue: #41408)")]
188188
public class EmptyFiltersAggregationUsageTests : AggregationUsageTestBase
189189
{
190190
public EmptyFiltersAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { }
@@ -218,8 +218,8 @@ protected override void ExpectResponse(ISearchResponse<Project> response)
218218
}
219219
}
220220

221-
/**[float]
222-
* === Conditionless Filters */
221+
// hide
222+
[SkipVersion(">=7.2.0", "Fixed in 7.2.0 server, FiltersAggregation NPE when filters is empty #41459 (issue: #41408)")]
223223
public class ConditionlessFiltersAggregationUsageTests : AggregationUsageTestBase
224224
{
225225
public ConditionlessFiltersAggregationUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usage) { }

0 commit comments

Comments
 (0)