Skip to content

Commit 4442828

Browse files
committed
feat(Discovery v1): Discriminator for QueryAggreagation
1 parent 1502772 commit 4442828

File tree

8 files changed

+20
-7
lines changed

8 files changed

+20
-7
lines changed

src/IBM.Watson.Discovery.v1/Model/Calculation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace IBM.Watson.Discovery.v1.Model
2323
/// <summary>
2424
/// Calculation.
2525
/// </summary>
26-
public class Calculation
26+
public class Calculation : QueryAggregation
2727
{
2828
/// <summary>
2929
/// The field where the aggregation is located in the document.

src/IBM.Watson.Discovery.v1/Model/Filter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace IBM.Watson.Discovery.v1.Model
2323
/// <summary>
2424
/// Filter.
2525
/// </summary>
26-
public class Filter
26+
public class Filter : QueryAggregation
2727
{
2828
/// <summary>
2929
/// The match the aggregated results queried for.

src/IBM.Watson.Discovery.v1/Model/Histogram.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace IBM.Watson.Discovery.v1.Model
2323
/// <summary>
2424
/// Histogram.
2525
/// </summary>
26-
public class Histogram
26+
public class Histogram : QueryAggregation
2727
{
2828
/// <summary>
2929
/// The field where the aggregation is located in the document.

src/IBM.Watson.Discovery.v1/Model/Nested.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace IBM.Watson.Discovery.v1.Model
2323
/// <summary>
2424
/// Nested.
2525
/// </summary>
26-
public class Nested
26+
public class Nested : QueryAggregation
2727
{
2828
/// <summary>
2929
/// The area of the results the aggregation was restricted to.

src/IBM.Watson.Discovery.v1/Model/QueryAggregation.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,26 @@
1616
*/
1717

1818
using System.Collections.Generic;
19+
using JsonSubTypes;
1920
using Newtonsoft.Json;
2021

2122
namespace IBM.Watson.Discovery.v1.Model
2223
{
2324
/// <summary>
2425
/// An aggregation produced by Discovery to analyze the input provided.
2526
/// </summary>
27+
[JsonConverter(typeof(JsonSubtypes), "Type")]
28+
[JsonSubtypes.KnownSubType(typeof(Histogram), "histogram")]
29+
[JsonSubtypes.KnownSubType(typeof(Calculation), "max")]
30+
[JsonSubtypes.KnownSubType(typeof(Calculation), "min")]
31+
[JsonSubtypes.KnownSubType(typeof(Calculation), "average")]
32+
[JsonSubtypes.KnownSubType(typeof(Calculation), "sum")]
33+
[JsonSubtypes.KnownSubType(typeof(Calculation), "unique_count")]
34+
[JsonSubtypes.KnownSubType(typeof(Term), "term")]
35+
[JsonSubtypes.KnownSubType(typeof(Filter), "filter")]
36+
[JsonSubtypes.KnownSubType(typeof(Nested), "nested")]
37+
[JsonSubtypes.KnownSubType(typeof(Timeslice), "timeslice")]
38+
[JsonSubtypes.KnownSubType(typeof(TopHits), "top_hits")]
2639
public class QueryAggregation
2740
{
2841
/// <summary>

src/IBM.Watson.Discovery.v1/Model/Term.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace IBM.Watson.Discovery.v1.Model
2323
/// <summary>
2424
/// Term.
2525
/// </summary>
26-
public class Term
26+
public class Term : QueryAggregation
2727
{
2828
/// <summary>
2929
/// The field where the aggregation is located in the document.

src/IBM.Watson.Discovery.v1/Model/Timeslice.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace IBM.Watson.Discovery.v1.Model
2323
/// <summary>
2424
/// Timeslice.
2525
/// </summary>
26-
public class Timeslice
26+
public class Timeslice : QueryAggregation
2727
{
2828
/// <summary>
2929
/// The field where the aggregation is located in the document.

src/IBM.Watson.Discovery.v1/Model/TopHits.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace IBM.Watson.Discovery.v1.Model
2323
/// <summary>
2424
/// TopHits.
2525
/// </summary>
26-
public class TopHits
26+
public class TopHits : QueryAggregation
2727
{
2828
/// <summary>
2929
/// Number of top hits returned by the aggregation.

0 commit comments

Comments
 (0)