Migration to `@forestadmin/agent` - Need help replacing search operator on a JSON column

We’re migrating from forest-express-sequelize to @forestadmin/agent.

Need help replacing search operator on a JSON column.
Previously we had this in the collection fields:
image (21)

We can’t use flatteners because as specified in the see docs, the flattened fields can’t be searched/filtered on.

We then would need to use replaceSearch, but we haven’t found a way to make it look into the wanted attributes of the json column directly: it would be really helpful if we could specify as “field” (under conditions) the attribute in the json column, but we can only specify proper fields and relationships.

One workaround could be to first make a query to get the records matching the logic we want and then return it in an “or” condition with the default search, but this would mean we are making double the queries for each search.

How can we achieve the same result we had before?

Thank you,
Matteo

Here is the “meta” section of the forest admin schema file:

  {
    "liana": "forest-nodejs-agent",
    "liana_version": "1.41.7",
    "liana_features": null,
    "stack": {"engine": "nodejs", "engine_version": "20.11.1"}
  }

and from package.json:

"sequelize": "^6.28.0"

cc @julien.jolles

Hello @Matteo,

Thanks for the detailed description and your use case.

It’s not implemented yet but could be a natural evolution of the plugin.
We could easily and automatically substitute the filtering capabilities (and thus the search). The solution would be to add replaceFieldOperator for all operators needed to support to enable the search on all fields resulting in the flattening.

That’s an interesting feedback. Indeed we only show (and have access) to forest managed fields. I will share your feedback to the teams. Maybe we can come up with a new syntax to access nested properties in a json something like myField.jsonField->nestedProperty (it’s really hypothetical for now).

I agree with you, this is not the right path to follow (even if it could work in the meanwhile).


So to sum up we can extend the functionality of our flattenjsoncolumn plugin to enable both filtering and search behaviours. I cannot give you an ETA about a release I will sync with the teams to see what we can do and when. Or if you’re willing to contribute we are very open to external contribution on our public repositories. :pray:

Kind regards,
Morgan