Skip to content

Commit 7e400de

Browse files
authored
Merge pull request #840 from watson-developer-cloud/discovery/fix-array-params
refactor: in `query` and `federatedQuery`, only accept string values
2 parents 0ea5683 + db71919 commit 7e400de

File tree

2 files changed

+28
-40
lines changed

2 files changed

+28
-40
lines changed

UPGRADE-4.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ The following services have been deprecated for an extended period of time and w
9797
- Parameter name changed: `passages.fields` -> `passages_fields`
9898
- Parameter name changed: `passages.count` -> `passages_count`
9999
- Parameter name changed: `passages.characters` -> `passages_characters`
100+
- Parameter type changed from Array to String: `return_fields`, `sort`, `passages_fields`, `collection_ids`, `similar_document_ids`, `similar_fields`
101+
102+
#### federatedQuery
103+
- Parameter type changed from Array to String: `return_fields`, `sort`, `passages_fields`, `collection_ids`, `similar_document_ids`, `similar_fields`
100104

101105
#### model QueryResultResultMetadata
102106
- Model name changed: `QueryResultResultMetadata` -> `QueryResultMetadata`

discovery/v1-generated.ts

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,16 +2006,16 @@ class DiscoveryV1 extends BaseService {
20062006
* with filters. Useful for applications to build lists, tables, and time series. For a full list of possible
20072007
* aggregations, see the Query reference.
20082008
* @param {number} [params.count] - Number of results to return.
2009-
* @param {string[]} [params.return_fields] - A comma-separated list of the portion of the document hierarchy to return.
2009+
* @param {string} [params.return_fields] - A comma-separated list of the portion of the document hierarchy to return.
20102010
* @param {number} [params.offset] - The number of query results to skip at the beginning. For example, if the total
20112011
* number of results that are returned is 10 and the offset is 8, it returns the last two results.
2012-
* @param {string[]} [params.sort] - A comma-separated list of fields in the document to sort on. You can optionally
2012+
* @param {string} [params.sort] - A comma-separated list of fields in the document to sort on. You can optionally
20132013
* specify a sort direction by prefixing the field with `-` for descending or `+` for ascending. Ascending is the
20142014
* default sort direction if no prefix is specified. This parameter cannot be used in the same query as the **bias**
20152015
* parameter.
20162016
* @param {boolean} [params.highlight] - When true, a highlight field is returned for each result which contains the
20172017
* fields which match the query with `<em></em>` tags around the matching query terms.
2018-
* @param {string[]} [params.passages_fields] - A comma-separated list of fields that passages are drawn from. If this
2018+
* @param {string} [params.passages_fields] - A comma-separated list of fields that passages are drawn from. If this
20192019
* parameter not specified, then all top-level fields are included.
20202020
* @param {number} [params.passages_count] - The maximum number of passages to return. The search returns fewer
20212021
* passages if the requested total is not found. The default is `10`. The maximum is `100`.
@@ -2026,16 +2026,16 @@ class DiscoveryV1 extends BaseService {
20262026
* @param {string} [params.deduplicate_field] - When specified, duplicate results based on the field specified are
20272027
* removed from the returned results. Duplicate comparison is limited to the current query only, **offset** is not
20282028
* considered. This parameter is currently Beta functionality.
2029-
* @param {string[]} [params.collection_ids] - A comma-separated list of collection IDs to be queried against. Required
2029+
* @param {string} [params.collection_ids] - A comma-separated list of collection IDs to be queried against. Required
20302030
* when querying multiple collections, invalid when performing a single collection query.
20312031
* @param {boolean} [params.similar] - When `true`, results are returned based on their similarity to the document IDs
20322032
* specified in the **similar.document_ids** parameter.
2033-
* @param {string[]} [params.similar_document_ids] - A comma-separated list of document IDs to find similar documents.
2033+
* @param {string} [params.similar_document_ids] - A comma-separated list of document IDs to find similar documents.
20342034
*
20352035
* **Tip:** Include the **natural_language_query** parameter to expand the scope of the document similarity search
20362036
* with the natural language query. Other query parameters, such as **filter** and **query**, are subsequently applied
20372037
* and reduce the scope.
2038-
* @param {string[]} [params.similar_fields] - A comma-separated list of field names that are used as a basis for
2038+
* @param {string} [params.similar_fields] - A comma-separated list of field names that are used as a basis for
20392039
* comparison to identify similar documents. If not specified, the entire document is used for comparison.
20402040
* @param {string} [params.bias] - Field which the returned results will be biased against. The specified field must
20412041
* be either a **date** or **number** format. When a **date** type field is specified returned results are biased
@@ -2064,14 +2064,6 @@ class DiscoveryV1 extends BaseService {
20642064
return _callback(missingParams);
20652065
}
20662066

2067-
// these params were arrays but now need to be strings, the following code is for compatibility
2068-
const nonArrayParams = ['return_fields', 'sort', 'passages_fields', 'collection_ids', 'similar_document_ids', 'similar_fields'];
2069-
nonArrayParams.forEach(paramName => {
2070-
if (Array.isArray(_params[paramName])) {
2071-
_params[paramName] = _params[paramName].join(',');
2072-
}
2073-
});
2074-
20752067
const body = {
20762068
'filter': _params.filter,
20772069
'query': _params.query,
@@ -2251,16 +2243,16 @@ class DiscoveryV1 extends BaseService {
22512243
* with filters. Useful for applications to build lists, tables, and time series. For a full list of possible
22522244
* aggregations, see the Query reference.
22532245
* @param {number} [params.count] - Number of results to return.
2254-
* @param {string[]} [params.return_fields] - A comma-separated list of the portion of the document hierarchy to return.
2246+
* @param {string} [params.return_fields] - A comma-separated list of the portion of the document hierarchy to return.
22552247
* @param {number} [params.offset] - The number of query results to skip at the beginning. For example, if the total
22562248
* number of results that are returned is 10 and the offset is 8, it returns the last two results.
2257-
* @param {string[]} [params.sort] - A comma-separated list of fields in the document to sort on. You can optionally
2249+
* @param {string} [params.sort] - A comma-separated list of fields in the document to sort on. You can optionally
22582250
* specify a sort direction by prefixing the field with `-` for descending or `+` for ascending. Ascending is the
22592251
* default sort direction if no prefix is specified. This parameter cannot be used in the same query as the **bias**
22602252
* parameter.
22612253
* @param {boolean} [params.highlight] - When true, a highlight field is returned for each result which contains the
22622254
* fields which match the query with `<em></em>` tags around the matching query terms.
2263-
* @param {string[]} [params.passages_fields] - A comma-separated list of fields that passages are drawn from. If this
2255+
* @param {string} [params.passages_fields] - A comma-separated list of fields that passages are drawn from. If this
22642256
* parameter not specified, then all top-level fields are included.
22652257
* @param {number} [params.passages_count] - The maximum number of passages to return. The search returns fewer
22662258
* passages if the requested total is not found. The default is `10`. The maximum is `100`.
@@ -2271,16 +2263,16 @@ class DiscoveryV1 extends BaseService {
22712263
* @param {string} [params.deduplicate_field] - When specified, duplicate results based on the field specified are
22722264
* removed from the returned results. Duplicate comparison is limited to the current query only, **offset** is not
22732265
* considered. This parameter is currently Beta functionality.
2274-
* @param {string[]} [params.collection_ids] - A comma-separated list of collection IDs to be queried against. Required
2266+
* @param {string} [params.collection_ids] - A comma-separated list of collection IDs to be queried against. Required
22752267
* when querying multiple collections, invalid when performing a single collection query.
22762268
* @param {boolean} [params.similar] - When `true`, results are returned based on their similarity to the document IDs
22772269
* specified in the **similar.document_ids** parameter.
2278-
* @param {string[]} [params.similar_document_ids] - A comma-separated list of document IDs to find similar documents.
2270+
* @param {string} [params.similar_document_ids] - A comma-separated list of document IDs to find similar documents.
22792271
*
22802272
* **Tip:** Include the **natural_language_query** parameter to expand the scope of the document similarity search
22812273
* with the natural language query. Other query parameters, such as **filter** and **query**, are subsequently applied
22822274
* and reduce the scope.
2283-
* @param {string[]} [params.similar_fields] - A comma-separated list of field names that are used as a basis for
2275+
* @param {string} [params.similar_fields] - A comma-separated list of field names that are used as a basis for
22842276
* comparison to identify similar documents. If not specified, the entire document is used for comparison.
22852277
* @param {string} [params.bias] - Field which the returned results will be biased against. The specified field must
22862278
* be either a **date** or **number** format. When a **date** type field is specified returned results are biased
@@ -2309,14 +2301,6 @@ class DiscoveryV1 extends BaseService {
23092301
return _callback(missingParams);
23102302
}
23112303

2312-
// these params were arrays but now need to be strings, the following code is for compatibility
2313-
const nonArrayParams = ['return_fields', 'sort', 'passages_fields', 'collection_ids', 'similar_document_ids'];
2314-
nonArrayParams.forEach(paramName => {
2315-
if (Array.isArray(_params[paramName])) {
2316-
_params[paramName] = _params[paramName].join(',');
2317-
}
2318-
});
2319-
23202304
const body = {
23212305
'filter': _params.filter,
23222306
'query': _params.query,
@@ -4705,15 +4689,15 @@ namespace DiscoveryV1 {
47054689
/** Number of results to return. */
47064690
count?: number;
47074691
/** A comma-separated list of the portion of the document hierarchy to return. */
4708-
return_fields?: string[];
4692+
return_fields?: string;
47094693
/** The number of query results to skip at the beginning. For example, if the total number of results that are returned is 10 and the offset is 8, it returns the last two results. */
47104694
offset?: number;
47114695
/** A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by prefixing the field with `-` for descending or `+` for ascending. Ascending is the default sort direction if no prefix is specified. This parameter cannot be used in the same query as the **bias** parameter. */
4712-
sort?: string[];
4696+
sort?: string;
47134697
/** When true, a highlight field is returned for each result which contains the fields which match the query with `<em></em>` tags around the matching query terms. */
47144698
highlight?: boolean;
47154699
/** A comma-separated list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included. */
4716-
passages_fields?: string[];
4700+
passages_fields?: string;
47174701
/** The maximum number of passages to return. The search returns fewer passages if the requested total is not found. The default is `10`. The maximum is `100`. */
47184702
passages_count?: number;
47194703
/** The approximate number of characters that any one passage will have. */
@@ -4723,13 +4707,13 @@ namespace DiscoveryV1 {
47234707
/** When specified, duplicate results based on the field specified are removed from the returned results. Duplicate comparison is limited to the current query only, **offset** is not considered. This parameter is currently Beta functionality. */
47244708
deduplicate_field?: string;
47254709
/** A comma-separated list of collection IDs to be queried against. Required when querying multiple collections, invalid when performing a single collection query. */
4726-
collection_ids?: string[];
4710+
collection_ids?: string;
47274711
/** When `true`, results are returned based on their similarity to the document IDs specified in the **similar.document_ids** parameter. */
47284712
similar?: boolean;
47294713
/** A comma-separated list of document IDs to find similar documents. **Tip:** Include the **natural_language_query** parameter to expand the scope of the document similarity search with the natural language query. Other query parameters, such as **filter** and **query**, are subsequently applied and reduce the scope. */
4730-
similar_document_ids?: string[];
4714+
similar_document_ids?: string;
47314715
/** A comma-separated list of field names that are used as a basis for comparison to identify similar documents. If not specified, the entire document is used for comparison. */
4732-
similar_fields?: string[];
4716+
similar_fields?: string;
47334717
/** Field which the returned results will be biased against. The specified field must be either a **date** or **number** format. When a **date** type field is specified returned results are biased towards field values closer to the current date. When a **number** type field is specified, returned results are biased towards higher field values. This parameter cannot be used in the same query as the **sort** parameter. */
47344718
bias?: string;
47354719
/** If `true`, queries are not stored in the Discovery **Logs** endpoint. */
@@ -4793,15 +4777,15 @@ namespace DiscoveryV1 {
47934777
/** Number of results to return. */
47944778
count?: number;
47954779
/** A comma-separated list of the portion of the document hierarchy to return. */
4796-
return_fields?: string[];
4780+
return_fields?: string;
47974781
/** The number of query results to skip at the beginning. For example, if the total number of results that are returned is 10 and the offset is 8, it returns the last two results. */
47984782
offset?: number;
47994783
/** A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by prefixing the field with `-` for descending or `+` for ascending. Ascending is the default sort direction if no prefix is specified. This parameter cannot be used in the same query as the **bias** parameter. */
4800-
sort?: string[];
4784+
sort?: string;
48014785
/** When true, a highlight field is returned for each result which contains the fields which match the query with `<em></em>` tags around the matching query terms. */
48024786
highlight?: boolean;
48034787
/** A comma-separated list of fields that passages are drawn from. If this parameter not specified, then all top-level fields are included. */
4804-
passages_fields?: string[];
4788+
passages_fields?: string;
48054789
/** The maximum number of passages to return. The search returns fewer passages if the requested total is not found. The default is `10`. The maximum is `100`. */
48064790
passages_count?: number;
48074791
/** The approximate number of characters that any one passage will have. */
@@ -4811,13 +4795,13 @@ namespace DiscoveryV1 {
48114795
/** When specified, duplicate results based on the field specified are removed from the returned results. Duplicate comparison is limited to the current query only, **offset** is not considered. This parameter is currently Beta functionality. */
48124796
deduplicate_field?: string;
48134797
/** A comma-separated list of collection IDs to be queried against. Required when querying multiple collections, invalid when performing a single collection query. */
4814-
collection_ids?: string[];
4798+
collection_ids?: string;
48154799
/** When `true`, results are returned based on their similarity to the document IDs specified in the **similar.document_ids** parameter. */
48164800
similar?: boolean;
48174801
/** A comma-separated list of document IDs to find similar documents. **Tip:** Include the **natural_language_query** parameter to expand the scope of the document similarity search with the natural language query. Other query parameters, such as **filter** and **query**, are subsequently applied and reduce the scope. */
4818-
similar_document_ids?: string[];
4802+
similar_document_ids?: string;
48194803
/** A comma-separated list of field names that are used as a basis for comparison to identify similar documents. If not specified, the entire document is used for comparison. */
4820-
similar_fields?: string[];
4804+
similar_fields?: string;
48214805
/** Field which the returned results will be biased against. The specified field must be either a **date** or **number** format. When a **date** type field is specified returned results are biased towards field values closer to the current date. When a **number** type field is specified, returned results are biased towards higher field values. This parameter cannot be used in the same query as the **sort** parameter. */
48224806
bias?: string;
48234807
/** If `true`, queries are not stored in the Discovery **Logs** endpoint. */

0 commit comments

Comments
 (0)