11using System ;
2+ using System . Linq ;
23using Elasticsearch . Net ;
4+ using FluentAssertions ;
35using Nest ;
46using Tests . Framework ;
57using Tests . Framework . Integration ;
@@ -25,30 +27,30 @@ protected override LazyResponses ClientUsage() => Calls(
2527 protected override int ExpectStatusCode => 200 ;
2628 protected override bool ExpectIsValid => true ;
2729 protected override HttpMethod HttpMethod => HttpMethod . POST ;
28- protected override string UrlPath => "/project/_field_stats" ;
30+ protected override string UrlPath => "/project/_field_stats?level=indices " ;
2931
3032 protected override Func < FieldStatsDescriptor , IFieldStatsRequest > Fluent => d => d
31- . Fields ( Field < Project > ( p => p . Name ) ) ;
32-
33- // Causes a NPE on ES 2.0.0
33+ . Fields ( Fields < Project > ( "*" ) )
34+ . Level ( Level . Indices ) ;
35+ // TODO: These seem to never return stats...
3436 //.IndexConstraints(cs => cs
3537 // .IndexConstraint(Field<Project>(p => p.StartedOn), c => c
3638 // .MinValue(min => min
37- // .GreaterThanOrEqualTo("2014-01-01" )
39+ // .GreaterThanOrEqualTo(Project.Projects.Min(p => p.StartedOn).ToString("yyyy-MM-dd") )
3840 // .Format("date_optional_time")
3941 // )
4042 // .MaxValue(max => max
41- // .LessThan("2015-12-29" )
43+ // .LessThan(Project.Projects.Max(p => p.StartedOn).ToString("yyyy-MM-dd") )
4244 // .Format("date_optional_time")
4345 // )
4446 // )
4547 //);
4648
4749 protected override FieldStatsRequest Initializer => new FieldStatsRequest ( typeof ( Project ) )
4850 {
49- Fields = Field < Project > ( p => p . Name )
50-
51- // Causes a NPE on ES 2.0.0
51+ Fields = Fields < Project > ( "*" ) ,
52+ Level = Level . Indices ,
53+ // TODO: These seem to never return stats...
5254 //IndexConstraints = new IndexConstraints
5355 //{
5456 // {
@@ -57,17 +59,26 @@ protected override LazyResponses ClientUsage() => Calls(
5759 // {
5860 // MinValue = new IndexConstraintComparison
5961 // {
60- // GreaterThanOrEqualTo = "2014-01-01" ,
62+ // GreaterThanOrEqualTo = Project.Projects.Min(p => p.StartedOn).ToString("yyyy-MM-dd") ,
6163 // Format = "date_optional_time"
6264 // },
6365 // MaxValue = new IndexConstraintComparison
6466 // {
65- // LessThan = "2015-12-29" ,
67+ // LessThan = Project.Projects.Max(p => p.StartedOn).ToString("yyyy-MM-dd") ,
6668 // Format = "date_optional_time"
6769 // }
6870 // }
6971 // }
7072 //}
7173 } ;
74+
75+ protected override void ExpectResponse ( IFieldStatsResponse response )
76+ {
77+ foreach ( var index in response . Indices )
78+ {
79+ var stats = index . Value ;
80+ stats . Fields . Should ( ) . NotBeEmpty ( ) ;
81+ }
82+ }
7283 }
7384}
0 commit comments