1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Text ;
5+ using NUnit . Framework ;
6+
7+ namespace Nest . Tests . Integration . Reproduce
8+ {
9+ [ TestFixture ]
10+ public class Reproduce1908Tests : IntegrationTests
11+ {
12+ private const string DefaultIndex = "reproduce1908" ;
13+
14+ public class Polygon
15+ {
16+ public PolygonGeoShape VertexValues { get ; set ; }
17+ }
18+
19+ protected override IElasticClient Client
20+ {
21+ get
22+ {
23+ return new ElasticClient ( Settings ) ;
24+ }
25+ }
26+
27+ protected override IConnectionSettingsValues Settings
28+ {
29+ get
30+ {
31+ return new ConnectionSettings ( ElasticsearchConfiguration . CreateBaseUri ( ) , DefaultIndex )
32+ . SetMaximumAsyncConnections ( ElasticsearchConfiguration . MaxConnections )
33+ . DisableAutomaticProxyDetection ( false )
34+ . PrettyJson ( )
35+ . ExposeRawResponse ( )
36+ . SetDefaultPropertyNameInferrer ( p => p )
37+ . SetConnectionStatusHandler ( r =>
38+ {
39+ // log out the requests
40+ if ( r . Request != null )
41+ {
42+ Console . WriteLine ( "{0} {1} \n {2}\n " , r . RequestMethod . ToUpperInvariant ( ) , r . RequestUrl ,
43+ Encoding . UTF8 . GetString ( r . Request ) ) ;
44+ }
45+ else
46+ {
47+ Console . WriteLine ( "{0} {1}\n " , r . RequestMethod . ToUpperInvariant ( ) , r . RequestUrl ) ;
48+ }
49+
50+ if ( r . ResponseRaw != null )
51+ {
52+ Console . WriteLine ( "Status: {0}\n {1}\n \n {2}\n " ,
53+ r . HttpStatusCode ,
54+ Encoding . UTF8 . GetString ( r . ResponseRaw ) ,
55+ new string ( '-' , 30 ) ) ;
56+ }
57+ else
58+ {
59+ Console . WriteLine ( "Status: {0}\n \n {1}\n " ,
60+ r . HttpStatusCode ,
61+ new string ( '-' , 30 ) ) ;
62+ }
63+ } ) ;
64+ }
65+ }
66+
67+ [ Test ]
68+ public void TypePropertySerializesLowercaseWhenUsingPascalPropertyNameInferrer ( )
69+ {
70+ if ( Client . IndexExists ( DefaultIndex ) . Exists )
71+ Client . DeleteIndex ( DefaultIndex ) ;
72+
73+ Client . CreateIndex ( DefaultIndex , c => c
74+ . AddMapping < Polygon > ( m => m
75+ . MapFromAttributes ( )
76+ . Properties ( p => p
77+ . GeoShape ( g => g
78+ . Name ( f => f . VertexValues )
79+ )
80+ )
81+ )
82+ ) ;
83+
84+ Client . Index ( new Polygon
85+ {
86+ VertexValues = new PolygonGeoShape
87+ {
88+ Coordinates = new List < List < List < double > > >
89+ {
90+ new List < List < double > >
91+ {
92+ new List < double > { 45.50537109375 , 1.186438639445215 } ,
93+ new List < double > { 49.41650390625 , 5.922044619883305 } ,
94+ new List < double > { 54.5141601562 , 3.9957805129630253 } ,
95+ new List < double > { 52.7124023437 , - 1.208406497271858 } ,
96+ new List < double > { 48.3837890625 , - 0.615222552406841 } ,
97+ new List < double > { 45.50537109375 , 1.186438639445215 } ,
98+ }
99+ } ,
100+ }
101+ } ) ;
102+
103+ Client . Refresh ( r => r . Index ( DefaultIndex ) ) ;
104+
105+ var coordinates = new [ ] { 48.864686 , 2.351616 } ;
106+
107+ var response1 = Client . Search < Polygon > ( x => x
108+ . Query ( q => q
109+ . Filtered ( f => f
110+ . Filter ( g => g
111+ . GeoShapePoint ( "VertexValues" , d => d
112+ . Coordinates ( coordinates )
113+ . Relation ( GeoShapeRelation . Intersects )
114+ )
115+ )
116+ )
117+ )
118+ ) ;
119+
120+ Assert . IsTrue ( response1 . IsValid ) ;
121+ Assert . IsTrue ( response1 . Documents . Count ( ) == 1 ) ;
122+
123+ Client . DeleteIndex ( DefaultIndex ) ;
124+ }
125+ }
126+ }
0 commit comments