Skip to content
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

specify an alias near the index_name in an AR model #1045

Open
sr-akhil opened this issue Oct 26, 2022 · 1 comment
Open

specify an alias near the index_name in an AR model #1045

sr-akhil opened this issue Oct 26, 2022 · 1 comment

Comments

@sr-akhil
Copy link

sr-akhil commented Oct 26, 2022

I wanted to now whether it is possible to specify an alias near the index_name in an AR model so that the url the is getting hit can be made dynamic.

I am trying to use this gem for multi-tenant application which is currently using mySQL db with every tenant having his own db. So it would be helpful if any feature as the following is available so that the request URL used for PUT request become dynamic

E.g.

index_name 'test'
alias tenant_name

will result in the following request PUT test/_alias/tenant_name

using which it will be possible to configure required job at the Elasticsearch side

Thanks

@sr-akhil
Copy link
Author

If it will help anyone

  • creating a new alias every-time a new tenant is created
    Model.__elasticsearch__.client = Elasticsearch::Client.new(host: 'hostname'). indices.put_alias name: tenant_name, index: 'metastore', body: { routing: tenant_name, filter: { ... } }
  • In the AR model, use index_name {"#{tenant_name}"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant