File tree Expand file tree Collapse file tree 3 files changed +71
-2
lines changed Expand file tree Collapse file tree 3 files changed +71
-2
lines changed Original file line number Diff line number Diff line change @@ -294,7 +294,15 @@ public class AggregationContainer : IAggregationContainer
294
294
{
295
295
public IAdjacencyMatrixAggregation AdjacencyMatrix { get ; set ; }
296
296
297
- public AggregationDictionary Aggregations { get ; set ; }
297
+ // This is currently used to support deserializing the response from SQL Translate,
298
+ // which forms a response which uses "aggregations", rather than "aggs". Longer term
299
+ // it would be preferred to address that in Elasticsearch itself.
300
+ [ DataMember ( Name = "aggregations" ) ]
301
+ private AggregationDictionary _aggs ;
302
+
303
+ // ReSharper disable once ConvertToAutoProperty
304
+ public AggregationDictionary Aggregations { get => _aggs ; set => _aggs = value ; }
305
+
298
306
public IAverageAggregation Average { get ; set ; }
299
307
300
308
public IAverageBucketAggregation AverageBucket { get ; set ; }
Original file line number Diff line number Diff line change @@ -179,8 +179,15 @@ public partial interface ISearchRequest<TInferDocument> : ISearchRequest { }
179
179
[ DataContract ]
180
180
public partial class SearchRequest
181
181
{
182
+ // This is currently used to support deserializing the response from SQL Translate,
183
+ // which forms a response which uses "aggregations", rather than "aggs". Longer term
184
+ // it would be preferred to address that in Elasticsearch itself.
185
+ [ DataMember ( Name = "aggregations" ) ]
186
+ private AggregationDictionary _aggs ;
187
+
182
188
/// <inheritdoc />
183
- public AggregationDictionary Aggregations { get ; set ; }
189
+ // ReSharper disable once ConvertToAutoProperty
190
+ public AggregationDictionary Aggregations { get => _aggs ; set => _aggs = value ; }
184
191
/// <inheritdoc />
185
192
public IFieldCollapse Collapse { get ; set ; }
186
193
/// <inheritdoc />
Original file line number Diff line number Diff line change
1
+ // Licensed to Elasticsearch B.V under one or more agreements.
2
+ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
+ // See the LICENSE file in the project root for more information
4
+
5
+ using System ;
6
+ using System . Text ;
7
+ using System . Threading . Tasks ;
8
+ using Elastic . Elasticsearch . Xunit . XunitPlumbing ;
9
+ using Elasticsearch . Net ;
10
+ using FluentAssertions ;
11
+ using Nest ;
12
+
13
+ namespace Tests . Reproduce
14
+ {
15
+ public class GitHubIssue5201
16
+ {
17
+ private static readonly byte [ ] ResponseBytes = Encoding . UTF8 . GetBytes ( @"{
18
+ ""size"" : 0,
19
+ ""_source"" : false,
20
+ ""stored_fields"" : ""_none_"",
21
+ ""aggregations"" : {
22
+ ""groupby"" : {
23
+ ""composite"" : {
24
+ ""size"" : 1000,
25
+ ""sources"" : [
26
+ {
27
+ ""ccf51bfa"" : {
28
+ ""terms"" : {
29
+ ""field"" : ""id"",
30
+ ""missing_bucket"" : true,
31
+ ""order"" : ""asc""
32
+ }
33
+ }
34
+ }
35
+ ]
36
+ }
37
+ }
38
+ }
39
+ }" ) ;
40
+
41
+ [ U ] public async Task DeserializeAggregations ( )
42
+ {
43
+ var pool = new SingleNodeConnectionPool ( new Uri ( $ "http://localhost:9200") ) ;
44
+ var settings = new ConnectionSettings ( pool , new InMemoryConnection ( ResponseBytes ) ) ;
45
+ var client = new ElasticClient ( settings ) ;
46
+
47
+ var translateResponseAsync = await client . Sql . TranslateAsync ( t => t . Query ( "select UDFvarchar1, count(1) from interactions group by UDFvarchar1 order by UDFvarchar1" ) ) ;
48
+ translateResponseAsync . Result . Aggregations . Should ( ) . NotBeNull ( ) ;
49
+
50
+ var translateResponse = client . Sql . Translate ( t => t . Query ( "select UDFvarchar1, count(1) from interactions group by UDFvarchar1 order by UDFvarchar1" ) ) ;
51
+ translateResponse . Result . Aggregations . Should ( ) . NotBeNull ( ) ;
52
+ }
53
+ }
54
+ }
You can’t perform that action at this time.
0 commit comments