Aggregation + Text Match

27 views
Skip to first unread message

Stephen Couchman

unread,
Apr 14, 2016, 9:07:53 AM4/14/16
to ReactiveMongo - http://reactivemongo.org
Hi

I was wondering what the proper manner of doing sort by textScore in the aggregation pipeline was, in ReactiveMongo.


The mongodb docs say it should be entered as:

db.collection.aggregate(
   [
     { $match: { $text: { $search: "operating" } } },
     { $sort: { score: { $meta: "textScore" } } }
   ]
)


Unfortunately Sort in the AggregationFramework only seems to support Ascending and Descending of simple field names, and both SortOrder and PipelineOperator are sealed traits so I couldn't attempt to force a custom command in.


Thanks for any advice you can offer.

Cédric Chantepie

unread,
Apr 15, 2016, 7:29:45 AM4/15/16
to ReactiveMongo - http://reactivemongo.org
Hi,

You can use the 0.12.0-SNAPSHOT (see example); See the documentation tutorial.

Otherwise/meanwhile, you can try to implement a raw command.

Stephen Couchman

unread,
Apr 18, 2016, 4:56:14 PM4/18/16
to ReactiveMongo - http://reactivemongo.org
Thanks that should help a lot.
Reply all
Reply to author
Forward
0 new messages