Skip to content

Commit f0ab5dd

Browse files
feat(discov2): new aggregation types
BREAKING CHANGE: smartDocumentUnderstanding param removed BREAKING CHANGE: QueryAggregation structure changed BREAKING CHANGE: object type properties changed to Dictionaries
1 parent de18cc7 commit f0ab5dd

35 files changed

+800
-192
lines changed

src/IBM.Watson.Discovery.v2/DiscoveryService.cs

+36-43
Large diffs are not rendered by default.

src/IBM.Watson.Discovery.v2/IDiscoveryService.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2019, 2022.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ public partial interface IDiscoveryService
3030
DetailedResponse<object> DeleteProject(string projectId);
3131
DetailedResponse<ListFieldsResponse> ListFields(string projectId, List<string> collectionIds = null);
3232
DetailedResponse<ListCollectionsResponse> ListCollections(string projectId);
33-
DetailedResponse<CollectionDetails> CreateCollection(string projectId, string name, string description = null, string language = null, List<CollectionEnrichment> enrichments = null, CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding = null);
33+
DetailedResponse<CollectionDetails> CreateCollection(string projectId, string name, string description = null, string language = null, List<CollectionEnrichment> enrichments = null);
3434
DetailedResponse<CollectionDetails> GetCollection(string projectId, string collectionId);
3535
DetailedResponse<CollectionDetails> UpdateCollection(string projectId, string collectionId, string name = null, string description = null, List<CollectionEnrichment> enrichments = null);
3636
DetailedResponse<object> DeleteCollection(string projectId, string collectionId);

src/IBM.Watson.Discovery.v2/Model/CollectionDetails.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2020, 2022.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -66,7 +66,7 @@ public class CollectionDetails
6666
/// An object that describes the Smart Document Understanding model for a collection.
6767
/// </summary>
6868
[JsonProperty("smart_document_understanding", NullValueHandling = NullValueHandling.Ignore)]
69-
public CollectionDetailsSmartDocumentUnderstanding SmartDocumentUnderstanding { get; set; }
69+
public virtual CollectionDetailsSmartDocumentUnderstanding SmartDocumentUnderstanding { get; private set; }
7070
}
7171

7272
}

src/IBM.Watson.Discovery.v2/Model/ProjectDetails.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2020, 2021.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -84,7 +84,7 @@ public class TypeEnumValue
8484
/// Relevancy training status information for this project.
8585
/// </summary>
8686
[JsonProperty("relevancy_training_status", NullValueHandling = NullValueHandling.Ignore)]
87-
public ProjectListDetailsRelevancyTrainingStatus RelevancyTrainingStatus { get; set; }
87+
public virtual ProjectListDetailsRelevancyTrainingStatus RelevancyTrainingStatus { get; private set; }
8888
/// <summary>
8989
/// The number of collections configured in this project.
9090
/// </summary>

src/IBM.Watson.Discovery.v2/Model/ProjectListDetails.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2020, 2021.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -84,7 +84,7 @@ public class TypeEnumValue
8484
/// Relevancy training status information for this project.
8585
/// </summary>
8686
[JsonProperty("relevancy_training_status", NullValueHandling = NullValueHandling.Ignore)]
87-
public ProjectListDetailsRelevancyTrainingStatus RelevancyTrainingStatus { get; set; }
87+
public virtual ProjectListDetailsRelevancyTrainingStatus RelevancyTrainingStatus { get; private set; }
8888
/// <summary>
8989
/// The number of collections configured in this project.
9090
/// </summary>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2019, 2020.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,35 +15,151 @@
1515
*
1616
*/
1717

18+
using System.Collections.Generic;
1819
using JsonSubTypes;
1920
using Newtonsoft.Json;
2021

2122
namespace IBM.Watson.Discovery.v2.Model
2223
{
2324
/// <summary>
24-
/// An abstract aggregation type produced by Discovery to analyze the input provided.
25+
/// An object that defines how to aggregate query results.
26+
/// Classes which extend this class:
27+
/// - QueryAggregationQueryTermAggregation
28+
/// - QueryAggregationQueryGroupByAggregation
29+
/// - QueryAggregationQueryHistogramAggregation
30+
/// - QueryAggregationQueryTimesliceAggregation
31+
/// - QueryAggregationQueryNestedAggregation
32+
/// - QueryAggregationQueryFilterAggregation
33+
/// - QueryAggregationQueryCalculationAggregation
34+
/// - QueryAggregationQueryTopHitsAggregation
35+
/// - QueryAggregationQueryPairAggregation
36+
/// - QueryAggregationQueryTrendAggregation
37+
/// - QueryAggregationQueryTopicAggregation
2538
/// </summary>
2639
[JsonConverter(typeof(JsonSubtypes), "type")]
27-
[JsonSubtypes.KnownSubType(typeof(QueryTermAggregation), "term")]
28-
[JsonSubtypes.KnownSubType(typeof(QueryHistogramAggregation), "histogram")]
29-
[JsonSubtypes.KnownSubType(typeof(QueryTimesliceAggregation), "timeslice")]
30-
[JsonSubtypes.KnownSubType(typeof(QueryNestedAggregation), "nested")]
31-
[JsonSubtypes.KnownSubType(typeof(QueryFilterAggregation), "filter")]
32-
[JsonSubtypes.KnownSubType(typeof(QueryCalculationAggregation), "min")]
33-
[JsonSubtypes.KnownSubType(typeof(QueryCalculationAggregation), "max")]
34-
[JsonSubtypes.KnownSubType(typeof(QueryCalculationAggregation), "sum")]
35-
[JsonSubtypes.KnownSubType(typeof(QueryCalculationAggregation), "average")]
36-
[JsonSubtypes.KnownSubType(typeof(QueryCalculationAggregation), "unique_count")]
37-
[JsonSubtypes.KnownSubType(typeof(QueryTopHitsAggregation), "top_hits")]
38-
[JsonSubtypes.KnownSubType(typeof(QueryGroupByAggregation), "group_by")]
40+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryTermAggregation), "term")]
41+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryGroupByAggregation), "group_by")]
42+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryHistogramAggregation), "histogram")]
43+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryTimesliceAggregation), "timeslice")]
44+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryNestedAggregation), "nested")]
45+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryFilterAggregation), "filter")]
46+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryCalculationAggregation), "min")]
47+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryCalculationAggregation), "max")]
48+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryCalculationAggregation), "sum")]
49+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryCalculationAggregation), "average")]
50+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryCalculationAggregation), "unique_count")]
51+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryTopHitsAggregation), "top_hits")]
52+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryPairAggregation), "pair")]
53+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryTrendAggregation), "trend")]
54+
[JsonSubtypes.KnownSubType(typeof(QueryAggregationQueryTopicAggregation), "topic")]
3955
public class QueryAggregation
4056
{
57+
/// This ctor is protected to prevent instantiation of this base class.
58+
/// Instead, users should instantiate one of the subclasses listed below:
59+
/// - QueryAggregationQueryTermAggregation
60+
/// - QueryAggregationQueryGroupByAggregation
61+
/// - QueryAggregationQueryHistogramAggregation
62+
/// - QueryAggregationQueryTimesliceAggregation
63+
/// - QueryAggregationQueryNestedAggregation
64+
/// - QueryAggregationQueryFilterAggregation
65+
/// - QueryAggregationQueryCalculationAggregation
66+
/// - QueryAggregationQueryTopHitsAggregation
67+
/// - QueryAggregationQueryPairAggregation
68+
/// - QueryAggregationQueryTrendAggregation
69+
/// - QueryAggregationQueryTopicAggregation
70+
protected QueryAggregation()
71+
{
72+
}
73+
4174
/// <summary>
42-
/// The type of aggregation command used. Options include: term, histogram, timeslice, nested, filter, min, max,
43-
/// sum, average, unique_count, and top_hits.
75+
/// Specifies that the aggregation type is `term`.
4476
/// </summary>
4577
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
46-
public string Type { get; set; }
78+
public string Type { get; protected set; }
79+
/// <summary>
80+
/// The field in the document where the values come from.
81+
/// </summary>
82+
[JsonProperty("field", NullValueHandling = NullValueHandling.Ignore)]
83+
public string Field { get; protected set; }
84+
/// <summary>
85+
/// The number of results returned. Not returned if `relevancy:true` is specified in the request.
86+
/// </summary>
87+
[JsonProperty("count", NullValueHandling = NullValueHandling.Ignore)]
88+
public long? Count { get; protected set; }
89+
/// <summary>
90+
/// Identifier specified in the query request of this aggregation. Not returned if `relevancy:true` is specified
91+
/// in the request.
92+
/// </summary>
93+
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
94+
public string Name { get; protected set; }
95+
/// <summary>
96+
/// The path to the document field to scope subsequent aggregations to.
97+
/// </summary>
98+
[JsonProperty("path", NullValueHandling = NullValueHandling.Ignore)]
99+
public string Path { get; protected set; }
100+
/// <summary>
101+
/// Number of nested documents found in the specified field.
102+
/// </summary>
103+
[JsonProperty("matching_results", NullValueHandling = NullValueHandling.Ignore)]
104+
public long? MatchingResults { get; protected set; }
105+
/// <summary>
106+
/// An array of subaggregations.
107+
/// </summary>
108+
[JsonProperty("aggregations", NullValueHandling = NullValueHandling.Ignore)]
109+
public List<Dictionary<string, object>> Aggregations { get; protected set; }
110+
/// <summary>
111+
/// The filter that is written in Discovery Query Language syntax and is applied to the documents before
112+
/// subaggregations are run.
113+
/// </summary>
114+
[JsonProperty("match", NullValueHandling = NullValueHandling.Ignore)]
115+
public string Match { get; protected set; }
116+
/// <summary>
117+
/// The value of the calculation.
118+
/// </summary>
119+
[JsonProperty("value", NullValueHandling = NullValueHandling.Ignore)]
120+
public double? Value { get; protected set; }
121+
/// <summary>
122+
/// The number of documents to return.
123+
/// </summary>
124+
[JsonProperty("size", NullValueHandling = NullValueHandling.Ignore)]
125+
public long? Size { get; protected set; }
126+
/// <summary>
127+
/// A query response that contains the matching documents for the preceding aggregations.
128+
/// </summary>
129+
[JsonProperty("hits", NullValueHandling = NullValueHandling.Ignore)]
130+
public QueryTopHitsAggregationResult Hits { get; protected set; }
131+
/// <summary>
132+
/// Specifies the first aggregation in the pair. The aggregation must be a `term`, `group_by`, `histogram`, or
133+
/// `timeslice` aggregation type.
134+
/// </summary>
135+
[JsonProperty("first", NullValueHandling = NullValueHandling.Ignore)]
136+
public string First { get; protected set; }
137+
/// <summary>
138+
/// Specifies the second aggregation in the pair. The aggregation must be a `term`, `group_by`, `histogram`, or
139+
/// `timeslice` aggregation type.
140+
/// </summary>
141+
[JsonProperty("second", NullValueHandling = NullValueHandling.Ignore)]
142+
public string Second { get; protected set; }
143+
/// <summary>
144+
/// Indicates whether to include estimated matching result information.
145+
/// </summary>
146+
[JsonProperty("show_estimated_matching_results", NullValueHandling = NullValueHandling.Ignore)]
147+
public bool? ShowEstimatedMatchingResults { get; protected set; }
148+
/// <summary>
149+
/// Indicates whether to include total matching documents information.
150+
/// </summary>
151+
[JsonProperty("show_total_matching_documents", NullValueHandling = NullValueHandling.Ignore)]
152+
public bool? ShowTotalMatchingDocuments { get; protected set; }
153+
/// <summary>
154+
/// Specifies the `term` or `group_by` aggregation for the facet that you want to analyze.
155+
/// </summary>
156+
[JsonProperty("facet", NullValueHandling = NullValueHandling.Ignore)]
157+
public string Facet { get; protected set; }
158+
/// <summary>
159+
/// Specifies the `timeslice` aggregation that defines the time segments.
160+
/// </summary>
161+
[JsonProperty("time_segments", NullValueHandling = NullValueHandling.Ignore)]
162+
public string TimeSegments { get; protected set; }
47163
}
48164

49165
}

src/IBM.Watson.Discovery.v2/Model/QueryCalculationAggregation.cs src/IBM.Watson.Discovery.v2/Model/QueryAggregationQueryCalculationAggregation.cs

+21-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2018, 2019.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,18 +23,35 @@ namespace IBM.Watson.Discovery.v2.Model
2323
/// Returns a scalar calculation across all documents for the field specified. Possible calculations include min,
2424
/// max, sum, average, and unique_count.
2525
/// </summary>
26-
public class QueryCalculationAggregation : QueryAggregation
26+
public class QueryAggregationQueryCalculationAggregation : QueryAggregation
2727
{
28+
/// <summary>
29+
/// Specifies the calculation type, such as 'average`, `max`, `min`, `sum`, or `unique_count`.
30+
/// </summary>
31+
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
32+
public new string Type
33+
{
34+
get { return base.Type; }
35+
set { base.Type = value; }
36+
}
2837
/// <summary>
2938
/// The field to perform the calculation on.
3039
/// </summary>
3140
[JsonProperty("field", NullValueHandling = NullValueHandling.Ignore)]
32-
public string Field { get; set; }
41+
public new string Field
42+
{
43+
get { return base.Field; }
44+
set { base.Field = value; }
45+
}
3346
/// <summary>
3447
/// The value of the calculation.
3548
/// </summary>
3649
[JsonProperty("value", NullValueHandling = NullValueHandling.Ignore)]
37-
public double? Value { get; set; }
50+
public new double? Value
51+
{
52+
get { return base.Value; }
53+
set { base.Value = value; }
54+
}
3855
}
3956

4057
}

src/IBM.Watson.Discovery.v2/Model/QueryFilterAggregation.cs src/IBM.Watson.Discovery.v2/Model/QueryAggregationQueryFilterAggregation.cs

+29-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2019, 2021.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,26 +21,47 @@
2121
namespace IBM.Watson.Discovery.v2.Model
2222
{
2323
/// <summary>
24-
/// A modifier that narrows the document set of the sub-aggregations it precedes.
24+
/// A modifier that narrows the document set of the subaggregations it precedes.
2525
/// </summary>
26-
public class QueryFilterAggregation : QueryAggregation
26+
public class QueryAggregationQueryFilterAggregation : QueryAggregation
2727
{
28+
/// <summary>
29+
/// Specifies that the aggregation type is `filter`.
30+
/// </summary>
31+
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
32+
public new string Type
33+
{
34+
get { return base.Type; }
35+
set { base.Type = value; }
36+
}
2837
/// <summary>
2938
/// The filter that is written in Discovery Query Language syntax and is applied to the documents before
30-
/// sub-aggregations are run.
39+
/// subaggregations are run.
3140
/// </summary>
3241
[JsonProperty("match", NullValueHandling = NullValueHandling.Ignore)]
33-
public string Match { get; set; }
42+
public new string Match
43+
{
44+
get { return base.Match; }
45+
set { base.Match = value; }
46+
}
3447
/// <summary>
3548
/// Number of documents that match the filter.
3649
/// </summary>
3750
[JsonProperty("matching_results", NullValueHandling = NullValueHandling.Ignore)]
38-
public long? MatchingResults { get; set; }
51+
public new long? MatchingResults
52+
{
53+
get { return base.MatchingResults; }
54+
set { base.MatchingResults = value; }
55+
}
3956
/// <summary>
40-
/// An array of sub-aggregations.
57+
/// An array of subaggregations.
4158
/// </summary>
4259
[JsonProperty("aggregations", NullValueHandling = NullValueHandling.Ignore)]
43-
public List<QueryAggregation> Aggregations { get; set; }
60+
public new List<Dictionary<string, object>> Aggregations
61+
{
62+
get { return base.Aggregations; }
63+
set { base.Aggregations = value; }
64+
}
4465
}
4566

4667
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* (C) Copyright IBM Corp. 2023.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using System.Collections.Generic;
19+
using Newtonsoft.Json;
20+
21+
namespace IBM.Watson.Discovery.v2.Model
22+
{
23+
/// <summary>
24+
/// Separates document results into groups that meet the conditions you specify.
25+
/// </summary>
26+
public class QueryAggregationQueryGroupByAggregation : QueryAggregation
27+
{
28+
/// <summary>
29+
/// Specifies that the aggregation type is `group_by`.
30+
/// </summary>
31+
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
32+
public new string Type
33+
{
34+
get { return base.Type; }
35+
set { base.Type = value; }
36+
}
37+
/// <summary>
38+
/// An array of results.
39+
/// </summary>
40+
[JsonProperty("results", NullValueHandling = NullValueHandling.Ignore)]
41+
public new List<QueryGroupByAggregationResult> Results { get; protected set; }
42+
}
43+
44+
}

0 commit comments

Comments
 (0)