How to improve search?

Feature(s) impacted


Observed behavior

Search don’t work on nested fields…

Expected behavior

How to enable search on nested fields?



I’m using forest admin with mongodb, and I’m wondering how to enable or how to add code to provide a search on nested fields? See example:

I’ve 2 collections

  • Users (each user is linked to a family with an ID)
  • Family
  • ID
  • Name

How to provide search from Users collection with the family name? from this input: (without advanced filters)


Thanks for your help,

That depends on which agent you are using.

With @forestadmin/agent (released last july), search can be customized by passing a custom handler to the replaceSearch method.

Here is the documentation:

With forest-express, the API is much lower level, and customers were expected to override the list route, and implement their own behavior there.

Here is the documentation:

Hello Romain!

Thanks for your quick response, I’m using forest-express-mongoose, so I need to use right?

And did you have any example of implementation ?



Any help on this topic? It’s really ruining our experience with Forest…


Hey @alex42 :wave:, and sorry for the super delayed response.

I’m using forest-express-mongoose

Are you using the fields flattener feature to deal with your nested fields ?

Hello @jeffladiray,

Thanks for your reply, my issue is more with populated (from other collections) fields (who are not searchable) and not about flattened fields (I guess)

To re-explain my problem, the “Account number” field is populated from another collection, but when I search “Himalia” in the search I got 0 results…

Thanks a lot for your help

Did you try with the extended search feature?

By default, search only works on the default fields available for your specific model, and extended search allow you to search inside belongsTo relations.

If it doesn’t work, a smart field referencing the field you want to search on + an implementation of the associated search could do the trick here.