Last active
August 29, 2015 14:18
-
-
Save lorgio/a37f011e39178924440e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WebSite.all.each do |web_site| | |
| next if web_site.s_id == 'evan_site_test' | |
| begin | |
| puts "checking for actual index..." | |
| response = UserSession.__elasticsearch__.client.perform_request('HEAD',web_site.namespaced_user_session_index_name,{}) | |
| UserSession.__elasticsearch__.client.perform_request('POST', '_aliases',{}, {actions: [{ add: { index: web_site.namespaced_user_session_index_name, alias: UserSession.index_name}}]}) | |
| rescue | |
| puts "index not found" | |
| puts "checking for alias" | |
| begin | |
| response = UserSession.__elasticsearch__.client.perform_request('GET',"_alias/#{web_site.namespaced_user_session_index_name}",{}) | |
| rescue Elasticsearch::Transport::Transport::Errors::NotFound | |
| puts "alias not found..." | |
| puts "creating alias to combined" | |
| UserSession.__elasticsearch__.client.perform_request('POST', '_aliases',{}, {actions: [{ add: { index: "user_sessions_combined", alias: web_site.namespaced_user_session_index_name }}]}) | |
| end | |
| end | |
| end | |
| UserSession.__elasticsearch__.client.perform_request('POST', '_aliases',{}, {actions: [{ add: { index: "user_sessions_combined", alias: UserSession.index_name}}]}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GET _cat/indices?v=true | |
| GET _cat/recovery?active_only=true | |
| GET _aliases | |
| POST _aliases | |
| { | |
| "actions": [ | |
| { | |
| "add": { | |
| "index": "34f39ed43ef00d65d1c57_user_sessions_staging", | |
| "alias": "user_sessions_staging" | |
| } | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment