Skip to content

Commit

Permalink
feat(aggregate): add Aggregate#search() for Atlas Text Search
Browse files Browse the repository at this point in the history
Fix #9115
  • Loading branch information
vkarpov15 committed Jun 14, 2020
1 parent 9609e87 commit 24f6a29
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/aggregate.js
Expand Up @@ -909,6 +909,32 @@ Aggregate.prototype.facet = function(options) {
return this.append({ $facet: options });
};

/**
* Helper for [Atlas Text Search](https://docs.atlas.mongodb.com/reference/atlas-search/tutorial/)'s
* `$search` stage.
*
* ####Example:
*
* Model.aggregate().
* search({
* text: {
* query: 'baseball',
* path: 'plot'
* }
* });
*
* // Output: [{ plot: '...', title: '...' }]
*
* @param {Object} $search options
* @return {Aggregate} this
* @see $search https://docs.atlas.mongodb.com/reference/atlas-search/tutorial/
* @api public
*/

Aggregate.prototype.search = function(options) {
return this.append({ $search: options });
};

/**
* Returns the current pipeline
*
Expand Down

0 comments on commit 24f6a29

Please sign in to comment.