-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple indexes? #138
Comments
Hi @9mm, having multiple indices is definitely an option to handle such a multi-tenant SAAS app but it actually slows down the indexing time (because we need to build N indices). Also, it's indeed not something supported by our Rails integration for now. There is actually a better approach: keeping both indexing time low & security. Instead of having 1 index per company, I would recommend you going for 1 single index for ALL companies and tag all records with their So a record will look like: {
"objectID": "42",
"name": "My book",
[...]
"_tags": ["company_1"]
} And at query time, you will generate an API key that is only able to search for records tagged with such company ID. The resulting API key can then be used in your JS frontend code. public_key = Algolia.generate_secured_api_key('SearchOnlyAPIKeyKeptPrivate', {filters: 'company_1'}) What do you think about that? |
Ah interesting, that also works quite nice then. 2 fast questions, if you wouldnt mind!
Even though I have no direct index for Thanks so much for your help. |
Cool :)
Tag are designed for filtering only. It could be done using a regular attribute + facet filters, but it would we slightly less efficient.
Yeah, that's something we need to work on because we don't have a strong answer. I think we should be able to reindex the parent object on touch like described in #74. In the meantime, I think the easiest is to trigger the If you want to work on #74, I would love to merge your contribution 👍 |
Ahh.. this makes sense. I'll keep that in mind, thanks again for your help! |
👍 You're welcome 💯 |
One thing I just thought of...
Is it possible to load facets/facet counts based on a tag?\
|
Nevermind, this is possible just did some testing... sweet. |
I have a SAAS app where each client/customer needs their own index (so basically multiple indexes of the same model).
Imagine each paying client has their own index of many
Book
records. This modelbelongs_to :company
so that each company gets their own database of books.Basically I want to create 1 index per company using this Rails gem on the
Book
model.How might I go about doing this? I see a few issues that might be tricky:
company_id
), so...1_Book
,2_Book
, etc.Associated attributes are already taken care of properly simply because it pulls the association properly.
Searching the right index is easy, based on just the UI.
Thanks!
The text was updated successfully, but these errors were encountered: