Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Commits on May 4, 2012
  1. [ALIASES] Added `Tire::Alias`, interface and DSL to manage aliases as…

    … resources
    * Added `Alias.all`, `Alias.all("some_index")` and `Alias.find("my_alias")`
    * Added rich interface for managing aliases as resources
    * Changed Index#add_alias and Index#remove_alias to use Tire::Alias interface
    * Changed the `Tire.aliases` method to use `Alias.all`
    * Added unit and integration tests
    See <> for feature overview.
    The `Tire::Alias` class provides a rich interface for managing aliases.
    To create an alias pointing to multiple indices:
        Tire::Alias.create name: 'my_alias', indices: ['index_1', 'index_2']
    You may pass the routing and other configurations:
        a = name:    'index_anne',
                            indices: ['index_2012_04', 'index_2012_03', 'index_2012_02'],
                            routing: 1,
                            filter:  { :terms => { :user => 'anne' } }
    Of course, you may use the Ruby API directly:
        a ='index_anne')
        # ...
    But you may prefer the DSL-ish block syntax:
    name: 'index_anne' do |a|
          a.index 'index_2012_04'
          a.index 'index_2012_03'
          a.filter :terms, username: 'anne'
    To update an existing alias, find it by name, update its configuration and save it:
        a = Tire::Alias.find('my_alias')
        a.indices.delete 'index_A'
        a.indices.add    'index_B'
        a.indices.add    'index_C'
    Or do it with a block, again:
        Tire::Alias.find('articles_aliased') do |a|
          a.indices.remove 'articles_2'
          puts '---', "#{} says: /me as JSON >", a.as_json, '---'

    To remove indices from alias, you may want to use the `Alias#indices.delete_if` method:
        require 'active_support/core_ext/numeric'
        require 'active_support/core_ext/date/calculations'
        a = Tire::Alias.find('articles_aliased')
        a.indices.delete_if do |i|
          Time.parse( i.gsub(/articles_/, '') ) < 4.weeks.ago rescue false
    To get all aliases, use the `Tire::Alias.all` method:
        Tire::Alias.all.each do |a|
          puts "#{} points to: #{a.indices}"
    To get aliases for a specific index, pass its name to `Alias.all`:
        Tire::Alias.all('articles').each do |a|
          puts "Alias '#{}': #{a.inspect}."
    See the 'sliding window' scenario in the corresponding integration test:
    Fixes #62, fixes #92, fixes #209.
Commits on Apr 27, 2012
  1. [#209] Added support for creating index aliases with configuration, c…

    …leaned up
    * You can do `@index.add_alias 'index-aliased', :routing => '1'` now
    * Fixed incorrect curl-formatted logs from alias operations
    * More consistent naming
    * Fixed expectations for Ruby 1.8
    * Added integration test
    Fixes #209.
Something went wrong with that request. Please try again.