This is example one of document in MongoDB.
{
"content" : "I just said that before. I'll never be with you.",
"analysis" : [
{
"sentence" : "I just said that before.",
"sentiment" : "neutral",
"subject" : "I",
"expression" : "say"
},
{
"sentence" : "I'll never be with you.",
"sentiment" : "negative",
"subject" : "I",
"expression" : "be",
"label": "Farewell"
}
]
}
There every analysis element can has "label" or no.
I want to filter this document for put "label" in analysis element.
I need document list that analysis.label.count < analysis.count
I tried this query
{ $and: [{ "analysis": { $exists: true } }, { "analysis.label": { $exists: false } }] }.
But it returns only has no label in any analysis' element.
Do I need aggregate()? or find() with query?
.find({ "analysis.label": null }).{ $and: [{ "analysis": { $exists: true } }, { "analysis.label": null }] }It work! I don't know how 'null' works.