SaaS, Multi-tenant, User defined fields (custom fields)

We’re building a kind of an address book as multi-tenant/saas/clould solution. The part about multi-tenancy seems to be clear

The question is about a feature where each tenant has the ability to define custom fields for contacts (might be tens of fields). The requirement is to be able to provide decent performance for custom queries, even against custom fields. Let’s say that we even expect millions of documents per tenant.

The straightforward approach seems to be defining custom fields as the top or the child level fields inside the main contact document. Partial indexes could be set per tenant per needs. Is there some kind of a negative side-effect of this approach?

The other one is to simulate notorious EAV model from relational databases and “vertically” store custom data in the same field. Usually this approach should be avoided, but not sure, might be something which is optimal for CB?

Or there might be some other optimal solution tailored particularly for CB due to its unique features?


It really depends.

For the known fields you could store that in a specific docType, and index those quite specifically.
For the custom fields maybe put them in another docType and index those with TOKEN

Thanks for the reply!
I’ll investigate token further, but from the first glance I’m not sure if it will allow us searching on custom values per operators eg. >, <, etc.
Eg. let’s say that there are custom fields like age, gender, city , there we should be able to find all female in theirs thirties living in London.

To Know More about SaaS Multi tenant you can check