1
votes

I have a collection of "evaluations", each evaluation with the following structure:

enter image description here

And I have a list of labels to filters with this sample structure:

[{ LabelId="5fe34b13f0031e1078e08b5c", Value="BOL"}, 
{ LabelId="5fe34b13f0031e1078e08b5c", Value="LGV"}]

What I want to do is filter "evaluations" collection to get only the evaluations that have EvaluationResults that have EvaluatedLabels that match the same LabelId and Value of the object filters in the list above.

In other words, I need the evaluations that evaluated the label/value combinations given.

How would I do that with mongodb query language using aggregation framework?

1

1 Answers

0
votes

You can create compound index on both fields as follow:

db.evaluations.createIndex({ "EvaluationResults.EvaluationLabels.LabelId":1, "EvaluationResults.EvaluationLabels.Value":1 })

and filter for specific evaluation as follow:

db.evaluations.find({ "EvaluationResults.EvaluationLabels.LabelId":"5fe", "EvaluationResults.EvaluationLabels.Value":"BOL" })