Search code examples
ruby-on-railsmulti-tenantsearchkickapartment-gem

Multi-tenant rails app with searchkick


Some information about my app:

  • Rails
  • Implements multi-tenancy with using apartment gem
  • Uses Elasticsearch through searchkick gem

Multi-tenancy will mean that there will be overlapping IDs for the same model.

First thing that came to my mind was to use searchkick's index_prefix, by setting index_prefix to the different tenant's name. But I realized that won't work because the value of index_prefix is set when the app starts. And the same value will remain throughout.


Solution

  • I received a reply from the creator of searchkick that is is not possible.

    https://github.com/ankane/searchkick/issues/268#issuecomment-53672954

    Now I might look for some monkey patching alternatives.