Answer the question
In order to leave comments, you need to log in
How to sort MongoDB selection by number of conditions met in $or?
I implement in the application something like a search by filters.
To select all documents that match at least one filter, I decided to use the $or operator and list all conditional filters in it. But now how can I sort the documents by the number of conditions met, so that first there are those that satisfied all the conditions, and at the very end those that satisfied one?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question