Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm trying to use a $facet stage of a aggregate pipeline to match and group documents, but I suspect my syntax is out.

Could anybody tell me what's wrong with this please? Keep getting the message "A Pipeline stage specification object must contain exact one field".

'$match': { 'Id': 59 '$unwind': { 'path': '$Vehicles' // It's this stage that's playing up. '$facet': { 'Offers': [ '$match': { 'Vehicles.VehicleGrouping': 'OOTW' }, '$group': { '_id': '$Vehicles.Manufacturer', 'count': { '$sum': 1 } // End of problematic stage.

Thanks.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question . Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers .