Skip to content

Commit

Permalink
Ignore Empty Filters tests (#3957)
Browse files Browse the repository at this point in the history
Elasticsearch 7.2.0 introduced a change to empty filters handling in elastic/elasticsearch#41459

(cherry picked from commit a8e502f)
  • Loading branch information
codebrain authored and Stuart Cam committed Jul 19, 2019
1 parent c6f929a commit 04e7c66
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 96 deletions.
4 changes: 4 additions & 0 deletions docs/aggregations.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ In addition to the buckets themselves, the bucket aggregations also compute and

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

* <<geo-tile-grid-aggregation-usage,Geo Tile Grid Aggregation Usage>>

* <<global-aggregation-usage,Global Aggregation Usage>>

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

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

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

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

include::aggregations/bucket/histogram/histogram-aggregation-usage.asciidoc[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,94 +237,3 @@ results.Last().DocCount.Should().Be(0); <1>
----
<1> The last bucket is the _other bucket_

[float]
=== Empty Filters

==== Fluent DSL example

[source,csharp]
----
a => a
.Filters("empty_filters", agg => agg
.AnonymousFilters()
)
----

==== Object Initializer syntax example

[source,csharp]
----
new FiltersAggregation("empty_filters")
{
Filters = new List<QueryContainer>()
}
----

[source,javascript]
.Example json output
----
{
"empty_filters": {
"filters": {
"filters": []
}
}
}
----

==== Handling Responses

[source,csharp]
----
response.ShouldBeValid();
response.Aggregations.Filters("empty_filters").Buckets.Should().BeEmpty();
----

[float]
=== Conditionless Filters

==== Fluent DSL example

[source,csharp]
----
a => a
.Filters("conditionless_filters", agg => agg
.AnonymousFilters(
q => new QueryContainer()
)
)
----

==== Object Initializer syntax example

[source,csharp]
----
new FiltersAggregation("conditionless_filters")
{
Filters = new List<QueryContainer>
{
new QueryContainer()
}
}
----

[source,javascript]
.Example json output
----
{
"conditionless_filters": {
"filters": {
"filters": []
}
}
}
----

==== Handling Responses

[source,csharp]
----
response.ShouldBeValid();
response.Aggregations.Filters("conditionless_filters").Buckets.Should().BeEmpty();
----

Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/7.0

:github: https://github.com/elastic/elasticsearch-net

:nuget: https://www.nuget.org/packages

////
IMPORTANT NOTE
==============
This file has been generated from https://github.com/elastic/elasticsearch-net/tree/master/src/Tests/Tests/Aggregations/Bucket/GeoHashTile/GeoTileGridAggregationUsageTests.cs.
If you wish to submit a PR for any spelling mistakes, typos or grammatical errors for this file,
please modify the original csharp file found at the link and submit the PR with that change. Thanks!
////

[[geo-tile-grid-aggregation-usage]]
=== Geo Tile Grid Aggregation Usage

==== Fluent DSL example

[source,csharp]
----
a => a
.GeoTile("my_geotile", g => g
.Field(p => p.LocationPoint)
.Precision(GeoTilePrecision.Precision3)
.Size(1000)
.ShardSize(100)
)
----

==== Object Initializer syntax example

[source,csharp]
----
new GeoTileGridAggregation("my_geotile")
{
Field = Field<Project>(p => p.LocationPoint),
Precision = GeoTilePrecision.Precision3,
Size = 1000,
ShardSize = 100
}
----

[source,javascript]
.Example json output
----
{
"my_geotile": {
"geotile_grid": {
"field": "locationPoint",
"precision": 3,
"size": 1000,
"shard_size": 100
}
}
}
----

==== Handling Responses

[source,csharp]
----
response.ShouldBeValid();
var myGeoTileTile = response.Aggregations.GeoTile("my_geotile");
myGeoTileTile.Should().NotBeNull();
myGeoTileTile.Buckets.FirstOrDefault(r => r.Key == "3/0/4").Should().NotBeNull();
myGeoTileTile.Buckets.FirstOrDefault(r => r.Key == "3/5/5").Should().NotBeNull();
----

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ The following is a list of available connection configuration options on `Connec
`ConnectionSettings` derives from `ConnectionConfiguration`, these options are available for both
the low level and high level client:

`ApiKeyAuthentication`::

Api Key to send with all requests to Elasticsearch

`ApiKeyAuthentication`::

Api Key to send with all requests to Elasticsearch

`BasicAuthentication`::

Basic Authentication credentials to send with all requests to Elasticsearch
Expand Down
42 changes: 42 additions & 0 deletions docs/mapping/scalar/scalar-usage.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ f => f
.Scalar(p => p.DateTimeOffsets, m => m)
.Scalar(p => p.DateTimeOffsetNullable, m => m)
.Scalar(p => p.DateTimeOffsetNullables, m => m)
.ScalarNanos(p => p.DateTimeNanos, m => m)
.ScalarNanos(p => p.DateTimeNanoss, m => m)
.ScalarNanos(p => p.DateTimeNanosNullable, m => m)
.ScalarNanos(p => p.DateTimeNanosNullables, m => m)
.ScalarNanos(p => p.DateTimeNanosOffset, m => m)
.ScalarNanos(p => p.DateTimeNanosOffsets, m => m)
.ScalarNanos(p => p.DateTimeNanosOffsetNullable, m => m)
.ScalarNanos(p => p.DateTimeNanosOffsetNullables, m => m)
.Scalar(p => p.Bool, m => m)
.Scalar(p => p.Bools, m => m)
.Scalar(p => p.BoolNullable, m => m)
Expand Down Expand Up @@ -168,6 +176,30 @@ null
"dateTimeOffsetNullables": {
"type": "date"
},
"dateTimeNanos": {
"type": "date_nanos"
},
"dateTimeNanoss": {
"type": "date_nanos"
},
"dateTimeNanosNullable": {
"type": "date_nanos"
},
"dateTimeNanosNullables": {
"type": "date_nanos"
},
"dateTimeNanosOffset": {
"type": "date_nanos"
},
"dateTimeNanosOffsets": {
"type": "date_nanos"
},
"dateTimeNanosOffsetNullable": {
"type": "date_nanos"
},
"dateTimeNanosOffsetNullables": {
"type": "date_nanos"
},
"decimal": {
"type": "double"
},
Expand Down Expand Up @@ -359,6 +391,16 @@ public class ScalarPoco
public IEnumerable<DateTimeOffset> DateTimeOffsets { get; set; }
public IEnumerable<DateTime> DateTimes { get; set; }
public DateTime DateTimeNanos { get; set; }
public DateTime? DateTimeNanosNullable { get; set; }
public IEnumerable<DateTime?> DateTimeNanosNullables { get; set; }
public DateTimeOffset DateTimeNanosOffset { get; set; }
public DateTimeOffset? DateTimeNanosOffsetNullable { get; set; }
public IEnumerable<DateTimeOffset?> DateTimeNanosOffsetNullables { get; set; }
public IEnumerable<DateTimeOffset> DateTimeNanosOffsets { get; set; }
public IEnumerable<DateTime> DateTimeNanoss { get; set; }
public decimal Decimal { get; set; }
public decimal? DecimalNullable { get; set; }
public IEnumerable<decimal?> DecimalNullables { get; set; }
Expand Down
57 changes: 57 additions & 0 deletions docs/x-pack/security/api-key/security-api-key-usage.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/7.0

:github: https://github.com/elastic/elasticsearch-net

:nuget: https://www.nuget.org/packages

////
IMPORTANT NOTE
==============
This file has been generated from https://github.com/elastic/elasticsearch-net/tree/master/src/Tests/Tests/XPack/Security/ApiKey/SecurityApiKeyUsageTests.cs.
If you wish to submit a PR for any spelling mistakes, typos or grammatical errors for this file,
please modify the original csharp file found at the link and submit the PR with that change. Thanks!
////

[[security-api-key-usage]]
=== Security Api Key Usage

==== Fluent DSL example

[source,csharp]
----
TryGetExtendedValue<CreateApiKeyResponse>("response", out var response);
// Unit tests for HitsTheCorrectUrl will have a null response object.
if (response == null)
return d => d;
return d => d.RequestConfiguration(r => r.ApiKeyAuthentication(response.Id, response.ApiKey));
----

==== Object Initializer syntax example

[source,csharp]
----
TryGetExtendedValue<CreateApiKeyResponse>("response", out var response);
// Unit tests for HitsTheCorrectUrl will have a null response object.
if (response == null)
return new NodesInfoRequest();
return new NodesInfoRequest
{
RequestConfiguration = new RequestConfiguration
{
ApiKeyAuthenticationCredentials = new ApiKeyAuthenticationCredentials(response.Id, response.ApiKey)
}
};
----

==== Handling Responses

[source,csharp]
----
response.IsValid.Should().BeTrue();
response.Nodes.Should().NotBeEmpty();
----

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Elastic.Xunit.XunitPlumbing;
using FluentAssertions;
using Nest;
using Tests.Core.Extensions;
Expand Down Expand Up @@ -182,9 +183,8 @@ protected override void ExpectResponse(ISearchResponse<Project> response)
}
}

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

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

0 comments on commit 04e7c66

Please sign in to comment.