Skip to content

Commit

Permalink
feat(discovery-v1): document status & query aggregation update
Browse files Browse the repository at this point in the history
DocumentStatus: documentID, status, and statusDescription are now optional. QueryAggregation:
BREAKING QueryAggregation subclasses changed.

BREAKING CHANGE: QueryAggregation: BREAKING QueryAggregation subclasses changed.
  • Loading branch information
kevinkowa committed Mar 18, 2022
1 parent 96d610f commit 776048c
Show file tree
Hide file tree
Showing 22 changed files with 569 additions and 515 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2020.
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -237,16 +237,11 @@ public Boolean overwrite() {
/**
* Gets the enrichment.
*
* <p>Name of the enrichment service to call. Current options are `natural_language_understanding`
* and `elements`.
* <p>Name of the enrichment service to call. The only supported option is
* `natural_language_understanding`. The `elements` option is deprecated and support ended on 10
* July 2020.
*
* <p>When using `natual_language_understanding`, the **options** object must contain Natural
* Language Understanding options.
*
* <p>When using `elements` the **options** object must contain Element Classification options.
* Additionally, when using the `elements` enrichment the configuration specified and files
* ingested must meet all the criteria specified in [the
* documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-element-classification#element-classification).
* <p>The **options** object must contain Natural Language Understanding options.
*
* @return the enrichment
*/
Expand All @@ -269,7 +264,11 @@ public Boolean ignoreDownstreamErrors() {
/**
* Gets the options.
*
* <p>Options which are specific to a particular enrichment.
* <p>Options that are specific to a particular enrichment.
*
* <p>The `elements` enrichment type is deprecated. Use the [Create a
* project](https://cloud.ibm.com/apidocs/discovery-data#createproject) method of the Discovery v2
* API to create a `content_intelligence` project type instead.
*
* @return the options
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2021.
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -14,7 +14,13 @@

import com.ibm.cloud.sdk.core.service.model.GenericModel;

/** Options which are specific to a particular enrichment. */
/**
* Options that are specific to a particular enrichment.
*
* <p>The `elements` enrichment type is deprecated. Use the [Create a
* project](https://cloud.ibm.com/apidocs/discovery-data#createproject) method of the Discovery v2
* API to create a `content_intelligence` project type instead.
*/
public class EnrichmentOptions extends GenericModel {

/**
Expand Down Expand Up @@ -151,8 +157,8 @@ public String language() {
/**
* Gets the model.
*
* <p>For use with `elements` enrichments only. The element extraction model to use. The only
* model available is `contract`.
* <p>The element extraction model to use, which can be `contract` only. The `elements` enrichment
* is deprecated.
*
* @return the model
*/
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2020.
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -12,9 +12,7 @@
*/
package com.ibm.watson.discovery.v1.model;

import com.google.gson.annotations.SerializedName;
import com.ibm.cloud.sdk.core.service.model.GenericModel;
import java.util.List;

/** An aggregation produced by Discovery to analyze the input provided. */
public class QueryAggregation extends GenericModel {
Expand All @@ -25,26 +23,20 @@ public class QueryAggregation extends GenericModel {

static {
discriminatorMapping = new java.util.HashMap<>();
discriminatorMapping.put("histogram", Histogram.class);
discriminatorMapping.put("max", Calculation.class);
discriminatorMapping.put("min", Calculation.class);
discriminatorMapping.put("average", Calculation.class);
discriminatorMapping.put("sum", Calculation.class);
discriminatorMapping.put("unique_count", Calculation.class);
discriminatorMapping.put("term", Term.class);
discriminatorMapping.put("filter", Filter.class);
discriminatorMapping.put("nested", Nested.class);
discriminatorMapping.put("timeslice", Timeslice.class);
discriminatorMapping.put("top_hits", TopHits.class);
discriminatorMapping.put("histogram", QueryHistogramAggregation.class);
discriminatorMapping.put("max", QueryCalculationAggregation.class);
discriminatorMapping.put("min", QueryCalculationAggregation.class);
discriminatorMapping.put("average", QueryCalculationAggregation.class);
discriminatorMapping.put("sum", QueryCalculationAggregation.class);
discriminatorMapping.put("unique_count", QueryCalculationAggregation.class);
discriminatorMapping.put("term", QueryTermAggregation.class);
discriminatorMapping.put("filter", QueryFilterAggregation.class);
discriminatorMapping.put("nested", QueryNestedAggregation.class);
discriminatorMapping.put("timeslice", QueryTimesliceAggregation.class);
discriminatorMapping.put("top_hits", QueryTopHitsAggregation.class);
}

protected String type;
protected List<AggregationResult> results;

@SerializedName("matching_results")
protected Long matchingResults;

protected List<QueryAggregation> aggregations;

/**
* Gets the type.
Expand All @@ -56,37 +48,4 @@ public class QueryAggregation extends GenericModel {
public String getType() {
return type;
}

/**
* Gets the results.
*
* <p>Array of aggregation results.
*
* @return the results
*/
public List<AggregationResult> getResults() {
return results;
}

/**
* Gets the matchingResults.
*
* <p>Number of matching results.
*
* @return the matchingResults
*/
public Long getMatchingResults() {
return matchingResults;
}

/**
* Gets the aggregations.
*
* <p>Aggregations returned by Discovery.
*
* @return the aggregations
*/
public List<QueryAggregation> getAggregations() {
return aggregations;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2020.
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -12,16 +12,19 @@
*/
package com.ibm.watson.discovery.v1.model;

/** Calculation. */
public class Calculation extends QueryAggregation {
/**
* Returns a scalar calculation across all documents for the field specified. Possible calculations
* include min, max, sum, average, and unique_count.
*/
public class QueryCalculationAggregation extends QueryAggregation {

protected String field;
protected Double value;

/**
* Gets the field.
*
* <p>The field where the aggregation is located in the document.
* <p>The field to perform the calculation on.
*
* @return the field
*/
Expand All @@ -32,7 +35,7 @@ public String getField() {
/**
* Gets the value.
*
* <p>Value of the aggregation.
* <p>The value of the calculation.
*
* @return the value
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.ibm.watson.discovery.v1.model;

import com.google.gson.annotations.SerializedName;
import java.util.List;

/** A modifier that narrows the document set of the sub-aggregations it precedes. */
public class QueryFilterAggregation extends QueryAggregation {

protected String match;

@SerializedName("matching_results")
protected Long matchingResults;

protected List<QueryAggregation> aggregations;

/**
* Gets the match.
*
* <p>The filter that is written in Discovery Query Language syntax and is applied to the
* documents before sub-aggregations are run.
*
* @return the match
*/
public String getMatch() {
return match;
}

/**
* Gets the matchingResults.
*
* <p>Number of documents that match the filter.
*
* @return the matchingResults
*/
public Long getMatchingResults() {
return matchingResults;
}

/**
* Gets the aggregations.
*
* <p>An array of sub-aggregations.
*
* @return the aggregations
*/
public List<QueryAggregation> getAggregations() {
return aggregations;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2019, 2020.
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -12,16 +12,23 @@
*/
package com.ibm.watson.discovery.v1.model;

/** Histogram. */
public class Histogram extends QueryAggregation {
import java.util.List;

/**
* Numeric interval segments to categorize documents by using field values from a single numeric
* field to describe the category.
*/
public class QueryHistogramAggregation extends QueryAggregation {

protected String field;
protected Long interval;
protected String name;
protected List<QueryHistogramAggregationResult> results;

/**
* Gets the field.
*
* <p>The field where the aggregation is located in the document.
* <p>The numeric field name used to create the histogram.
*
* @return the field
*/
Expand All @@ -32,11 +39,33 @@ public String getField() {
/**
* Gets the interval.
*
* <p>Interval of the aggregation. (For 'histogram' type).
* <p>The size of the sections that the results are split into.
*
* @return the interval
*/
public Long getInterval() {
return interval;
}

/**
* Gets the name.
*
* <p>Identifier specified in the query request of this aggregation.
*
* @return the name
*/
public String getName() {
return name;
}

/**
* Gets the results.
*
* <p>Array of numeric intervals.
*
* @return the results
*/
public List<QueryHistogramAggregationResult> getResults() {
return results;
}
}

0 comments on commit 776048c

Please sign in to comment.