I have documents like this
{ "_id" : 1, "item" : { "code": "ABC1", skus: [ "c1", "c2", "c3"] }
{ "_id" : 2, "item" : { "code": "ABC2", skus: [ "c1", "c2", "d3"] }
{ "_id" : 3, "item" : { "code": "ABC3", skus: [ "d1", "d2", "c3"] }
search all those docs matching the input sku array
["c1", "d3"]
{ "_id" : 1, "item" : { "code": "ABC1", skus: [ "c1", "c2", "c3"] }
{ "_id" : 2, "item" : { "code": "ABC2", skus: [ "c1", "c2", "d3"] }
the requirement is if the skus contain at least one element from the input search array then the full document should be returned
Any help is much appreciated
The query response should return the full documents in original , not any trimmed doc
Thanks
Sree
I have tried unwind and group for reversing the unwind but group doesn’t return the full document after projection
New contributor
Suresh London is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.