Skip to content

Commit adcd275

Browse files
committed
🆕[discovery] Add sort parameter for Discovery query
1 parent c230df7 commit adcd275

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

discovery/v1.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,13 @@ DiscoveryV1.prototype.deleteDocument = function(params, callback) {
445445
* @param {Object} params
446446
* @param {String} params.environment_id
447447
* @param {string} params.collection_id
448-
* @param {String} [params.filter] A cacheable query that allows you to limit the information returned to exclude anything that isn't related to what you are searching. Filter searches are better for metadata type searches and when you are trying to get a sense of concepts in the dataset.
449448
* @param {String} [params.query] A query search returns all possible results, even when it's not very relevant, with the most relevant documents listed first. Use a query search when you want to find the most relevant search results. Results are scored between 0 and 1, with 1 being an exact match and 0 being not a match at all.
449+
* @param {String} [params.filter] A cacheable query that allows you to limit the information returned to exclude anything that isn't related to what you are searching. Filter searches are better for metadata type searches and when you are trying to get a sense of concepts in the dataset.
450450
* @param {String} [params.aggregation] An aggregation search uses combinations of filters and query search to return an exact answer. Aggregations are useful for building applications, because you can use them to build lists, tables, and time series. For a full list of possible aggregrations, see the Query reference.
451451
* @param {Number} [params.count=10] Number of documents to return
452-
* @param {String} [params.return] A comma separated list of the portion of the document hierarchy to return.
453452
* @param {Number} [params.offset=0] For pagination purposes. Returns additional pages of results. Deep pagination is highly unperformant, and should be avoided.
453+
* @param {String} [params.return] A comma separated list of the portion of the document hierarchy to return.
454+
* @param {String} [params.sort] 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.
454455
*/
455456
DiscoveryV1.prototype.query = function(params, callback) {
456457
params = params || {};
@@ -461,7 +462,7 @@ DiscoveryV1.prototype.query = function(params, callback) {
461462
method: 'GET',
462463
json: true,
463464
path: pick(params, ['environment_id', 'collection_id']),
464-
qs: pick(params, ['filter', 'aggregation', 'return', 'count', 'offset', 'query'])
465+
qs: pick(params, ['query', 'filter', 'aggregation', 'count', 'offset', 'return', 'sort'])
465466
},
466467
requiredParams: ['environment_id', 'collection_id'],
467468
defaultOptions: this._options

test/unit/test.discovery.v1.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,12 @@ describe('discovery-v1', function() {
199199
environment_id: 'env-guid',
200200
collection_id: 'col-guid',
201201
filter: 'yesplease',
202-
count: 10
202+
count: 10,
203+
sort: '+field_1,-field_2'
203204
},
204205
noop
205206
);
206-
assert.equal(req.uri.href, service.url + paths.query + '?version=' + service.version_date + '&filter=yesplease&count=10');
207+
assert.equal(req.uri.href, service.url + paths.query + '?version=' + service.version_date + '&filter=yesplease&count=10&sort=%2Bfield_1%2C-field_2');
207208
assert.equal(req.method, 'GET');
208209
});
209210
});

0 commit comments

Comments
 (0)