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 @@ -295,7 +295,15 @@ public class AggregationContainer : IAggregationContainer
295
295
{
296
296
public IAdjacencyMatrixAggregation AdjacencyMatrix { get ; set ; }
297
297
298
- public AggregationDictionary Aggregations { get ; set ; }
298
+ // This is currently used to support deserializing the response from SQL Translate,
299
+ // which forms a response which uses "aggregations", rather than "aggs". Longer term
300
+ // it would be preferred to address that in Elasticsearch itself.
301
+ [ DataMember ( Name = "aggregations" ) ]
302
+ private AggregationDictionary _aggs ;
303
+
304
+ // ReSharper disable once ConvertToAutoProperty
305
+ public AggregationDictionary Aggregations { get => _aggs ; set => _aggs = value ; }
306
+
299
307
public IAverageAggregation Average { get ; set ; }
300
308
301
309
public IAverageBucketAggregation AverageBucket { get ; set ; }
Original file line number Diff line number Diff line change @@ -180,8 +180,15 @@ public partial interface ISearchRequest<TInferDocument> : ISearchRequest { }
180
180
[ DataContract ]
181
181
public partial class SearchRequest
182
182
{
183
+ // This is currently used to support deserializing the response from SQL Translate,
184
+ // which forms a response which uses "aggregations", rather than "aggs". Longer term
185
+ // it would be preferred to address that in Elasticsearch itself.
186
+ [ DataMember ( Name = "aggregations" ) ]
187
+ private AggregationDictionary _aggs ;
188
+
183
189
/// <inheritdoc />
184
- public AggregationDictionary Aggregations { get ; set ; }
190
+ // ReSharper disable once ConvertToAutoProperty
191
+ public AggregationDictionary Aggregations { get => _aggs ; set => _aggs = value ; }
185
192
/// <inheritdoc />
186
193
public IFieldCollapse Collapse { get ; set ; }
187
194
/// <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