Filter on referenced flattened fields are not working

Feature(s) impacted

  • Filters
  • Smart fields
  • Flattened fields

Observed behavior

When I try to filter on a flattened field, even tho my mongoose model is correctly defined, I get the following error:

Unexpected error: Field ‘parent.child’ not found on collection ‘CollectionName’

I’ve redacted the actual values but this should be enough.

Expected behavior

I’m expecting no errors and the filter to be applied properly

Failure Logs

Unexpected error: Field ‘parent.child’ not found on collection ‘CollectionName’


Current version of forest-express-mongoose is 8.4.4
Current version of mongoose is 5.13.13

I’m pretty much using all the basics, a mongoose model and a forest collection to flatten fields and add some smart fields

Sorry for the lack of images, but the image upload seems broken.

Hello @jganichot :wave:

Thanks for the thread :raised_hands:

I’ve successfully configured a filter on a flatten field using forest-express-mongoose v8.4.4.

Would you mind sharing your model file and the filter you attempted to configure please ? Here is mine:

Model used:

const schema = Mongoose.Schema({
    'company': { type: Mongoose.Schema.Types.ObjectId, ref: 'companies' },
    'engine': {
      'owner': { type: Mongoose.Schema.Types.ObjectId, ref: 'companies' },
      'identification': {
        'manufacturer': String,
        'company': Mongoose.Schema.Types.ObjectId,
      'horsePower': String,
      'companies': [Mongoose.Schema.Types.ObjectId],
      'comments': [{
        'date': Date,
        'comment': String,

Here is the collection configuration:

collection('cars', {
  actions: [],
  fields: [...],
  segments: [],
  fieldsToFlatten: ['engine'],

Here are some attempts to filter my data:


Hi Steve,

Thanks for sharing.

My bad, my original post is missing a very important piece of information.

It’s not working in the case where I’m filtering collection B on a flattened filed of a reference to collection A.

So let’s say I have collection A that looks like this:

const collectionA = new Schema({
  details: {
    name: String,

And collection B looks like this:

const collectionB = new Schema({
  foo: String,
  meta: {
    refToDocInCollectionA: {  type: Schema.Types.ObjectId, ref: 'CollectionA' },

Then I tried to filter the list of collection B using the flattened field details -> name of collection A with this filter: meta -> refToDocInCollectionA | details -> name | is | Joe

Something like this: