Have a collection with a hasOne relationship e.g. field: { type: mongoose.Schema.Types.ObjectId, ref: ‘accounts’ }
When trying to filter that this field is not blank, must select a sub field, I assume for there to be an aggregation. But my collection is too big and that aggregation times out. Want to just filter on values of the field. For examplein this particular case I want to make a filter “is present” on the field itself, not subfields
Actual behavior
What is the current behavior?
Failure Logs
Please include any relevant log snippets, if necessary.
Context
Please provide any relevant information about your setup.
If I understand well, you want to check if the relation exists, without checking a particular attribute of said related item?
eg: you want to filter users having a team, but without any consideration on that team.
I think a smart field would not be an efficient query and with the size of my collections would not work. For now I created a smart segment, but of course that is not ideal, since I will have to release new code when users want another variation fo the filter. Keep me informed if it makes it to the top of the roadmap.
If you just want to check that a relationship is present or not, why don’t you just filter on the subfield id
Something like: account.id is present or the opposite account.id is blank.
I assume there is some aggregation going on here with the related collection because on a big dataset, the aggregation is causing the query to timeout, whereas if you just query on the main collection with exists: false, it is not problem. I ended up having to create a custom segment around this.