File tree Expand file tree Collapse file tree 3 files changed +72
-2
lines changed Expand file tree Collapse file tree 3 files changed +72
-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 @@ -183,8 +183,15 @@ public partial interface ISearchRequest<TInferDocument> : ISearchRequest { }
183
183
[ DataContract ]
184
184
public partial class SearchRequest
185
185
{
186
+ // This is currently used to support deserializing the response from SQL Translate,
187
+ // which forms a response which uses "aggregations", rather than "aggs". Longer term
188
+ // it would be preferred to address that in Elasticsearch itself.
189
+ [ DataMember ( Name = "aggregations" ) ]
190
+ private AggregationDictionary _aggs ;
191
+
186
192
/// <inheritdoc />
187
- public AggregationDictionary Aggregations { get ; set ; }
193
+ // ReSharper disable once ConvertToAutoProperty
194
+ public AggregationDictionary Aggregations { get => _aggs ; set => _aggs = value ; }
188
195
/// <inheritdoc />
189
196
public IFieldCollapse Collapse { get ; set ; }
190
197
/// <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 Elastic . Transport ;
10
+ using Elasticsearch . Net ;
11
+ using FluentAssertions ;
12
+ using Nest ;
13
+
14
+ namespace Tests . Reproduce
15
+ {
16
+ public class GitHubIssue5201
17
+ {
18
+ private static readonly byte [ ] ResponseBytes = Encoding . UTF8 . GetBytes ( @"{
19
+ ""size"" : 0,
20
+ ""_source"" : false,
21
+ ""stored_fields"" : ""_none_"",
22
+ ""aggregations"" : {
23
+ ""groupby"" : {
24
+ ""composite"" : {
25
+ ""size"" : 1000,
26
+ ""sources"" : [
27
+ {
28
+ ""ccf51bfa"" : {
29
+ ""terms"" : {
30
+ ""field"" : ""id"",
31
+ ""missing_bucket"" : true,
32
+ ""order"" : ""asc""
33
+ }
34
+ }
35
+ }
36
+ ]
37
+ }
38
+ }
39
+ }
40
+ }" ) ;
41
+
42
+ [ U ] public async Task DeserializeAggregations ( )
43
+ {
44
+ var pool = new SingleNodeConnectionPool ( new Uri ( $ "http://localhost:9200") ) ;
45
+ var settings = new ConnectionSettings ( pool , new InMemoryConnection ( ResponseBytes ) ) ;
46
+ var client = new ElasticClient ( settings ) ;
47
+
48
+ var translateResponseAsync = await client . Sql . TranslateAsync ( t => t . Query ( "select UDFvarchar1, count(1) from interactions group by UDFvarchar1 order by UDFvarchar1" ) ) ;
49
+ translateResponseAsync . Result . Aggregations . Should ( ) . NotBeNull ( ) ;
50
+
51
+ var translateResponse = client . Sql . Translate ( t => t . Query ( "select UDFvarchar1, count(1) from interactions group by UDFvarchar1 order by UDFvarchar1" ) ) ;
52
+ translateResponse . Result . Aggregations . Should ( ) . NotBeNull ( ) ;
53
+ }
54
+ }
55
+ }
You can’t perform that action at this time.
0 commit comments