How to combine regex find and distinct?

For example, I am getting results with this query:

db.getCollection('crawler').find( { link: { $regex: /^https:\/\//i } } )

How can I also make ‘link’ distinct?

Much appreciated

   {$match: {"link": /^https:\/\//}}, 
   {$group: {"_id": "$link"}}

will give you all links that start with https://, distinct. May not be very efficient.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.