Permalink
Commits on Jul 31, 2012
  1. support nested query

    fcheung committed Jul 31, 2012
Commits on May 18, 2012
Commits on May 17, 2012
Commits on May 4, 2012
  1. Release 0.4.2

    karmi committed May 4, 2012
  2. [ALIASES] Added `Tire::Alias`, interface and DSL to manage aliases as…

    karmi committed May 2, 2012
    … 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 <http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases.html> 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 = Tire::Alias.new name:    'index_anne',
                            indices: ['index_2012_04', 'index_2012_03', 'index_2012_02'],
                            routing: 1,
                            filter:  { :terms => { :user => 'anne' } }
        a.save
    
    Of course, you may use the Ruby API directly:
    
        a = Tire::Alias.new
        a.name('index_anne')
        a.index('index_2012_04')
        a.index('index_2012_03')
        # ...
        a.save
    
    But you may prefer the DSL-ish block syntax:
    
        Tire::Alias.new name: 'index_anne' do |a|
          a.index 'index_2012_04'
          a.index 'index_2012_03'
          a.filter :terms, username: 'anne'
        end
    
    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'
        a.save
    
    Or do it with a block, again:
    
        Tire::Alias.find('articles_aliased') do |a|
          a.indices.remove 'articles_2'
          puts '---', "#{a.name} says: /me as JSON >", a.as_json, '---'
          a.save
        end
    
    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
        end
        a.save
    
    To get all aliases, use the `Tire::Alias.all` method:
    
        Tire::Alias.all.each do |a|
          puts "#{a.name.rjust(30)} points to: #{a.indices}"
        end
    
    To get aliases for a specific index, pass its name to `Alias.all`:
    
        Tire::Alias.all('articles').each do |a|
          puts "Alias '#{a.name}': #{a.inspect}."
        end
    
    See the 'sliding window' scenario in the corresponding integration test:
    
        <https://github.com/karmi/tire/blob/aliases/test/integration/index_aliases_test.rb#L66-118>
    
    Fixes #62, fixes #92, fixes #209.
  3. [FIX] Fixed, that blocks passed to `Tire::Index.new` or `Tire.index` …

    karmi committed May 4, 2012
    …losed the scope
    
    Without this patch, blocks being passed to `Tire::Index.new` losed the scope, because
    only `instance_eval` was called.
    
    This was inconsistent with the `Tire::Search.new` behaviour, as documented eg. in
    <http://karmi.github.com/tire/#section-48>
    
    Thanks to @ahfeel for reporting.
Commits on May 3, 2012
  1. Release 0.4.1

    karmi committed May 3, 2012
  2. Added Index#url and simplified the Tire::Index class and tests

    nz authored and karmi committed Apr 30, 2012
    Closes #328, fixes #327
  3. [BULK] Changed, that Index#bulk_store runs against an index endpoint,…

    karmi committed May 3, 2012
    … not against `/_bulk`
    
    
    Closes #327, fixes #328.
Commits on Apr 28, 2012
Commits on Apr 27, 2012
  1. [#209] Added support for creating index aliases with configuration, c…

    karmi committed Apr 27, 2012
    …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.
  2. Added support for index aliases

    woahdae authored and karmi committed Jan 18, 2012
    This commit adds support for:
    
    * Tire::aliases
    * Tire::Index#aliases
    * Tire::Index#add_alias
    * Tire::Index#remove_alias
    
    So, to add an alias for an index, you can do:
    
        Tire.index('articles') do
          add_alias 'articles_aliased
        end
    
    or:
    
        Tire.index('articles').add_alias 'articles_aliased'
    
    See the index unit tests for documentation.
    
    See <http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases.html>
    for more documentation on the feature in ElasticSearch.
    
    Closes #209, fixes #92.
  3. [TESTS] Fixed syntax errors in tests under Ruby 1.8

    timoschilling authored and karmi committed Apr 23, 2012
    Closes #321.
Commits on Mar 30, 2012
  1. Added support for reindexing the index documents into new index

    karmi committed Mar 30, 2012
    Added a `Tire::Index#reindex` method which uses the "scan/scroll" API to retrieve
    documents from index A and import them into index B.
    
    If the new index does not exists, it is created: you may pass settings as an options hash.
    
    You may pass a Tire DSL query as a block to the method.
    
    Example:
    --------
    
        require 'tire'
    
        Tire.configure { logger STDERR }
    
        Tire.index('scantest-new') { delete }
    
        documents = (1..100).map do |i|
          { id: i, type: 'test', title: "Document #{i}" }
        end
    
        puts "", "Importing data into ElasticSearch..."
    
        Tire.index 'scantest' do
          delete and create :settings => { :number_of_shards => 1, :number_of_replicas => 0 }
          import documents
          refresh
        end
    
        Tire.index('scantest').reindex 'scantest-new', settings: { number_of_shards: 3 } do
          query { string '10*' }
        end
  2. Added support for the "scan" search in the Ruby API

    karmi committed Mar 30, 2012
    Given the support for search types (since karmi/retire@d764c0d), we can now
    expose the "scan" search type in the Ruby API and DSL.
    
    Example
    -------
    
        # Let's index some data
        documents = (1..100).map { |i| { id: i, type: 'test', title: "Document #{i}" } }
    
        Tire.index 'scantest' do
          delete
          create :settings => { :number_of_shards => 1, :number_of_replicas => 0 }
          import documents
          refresh
        end
    
        # Let's initiate a scan search request
        s = Tire.scan 'scantest'
    
        # The #each method returns the document batches as received from ElasticSearch,
        # where invididual hits are wrapped as Results::Item
        s.each do |results|
          puts results.map(&:title)
        end
    
        # The #each_document method returns each individual documents, as received from ElasticSearch,
        # wrapped as a Results::Item
        s.each_document do |document|
          puts "#{count}: #{document.title}"
          count += 1
        end
    
    Information
    -----------
    
    The object being returned is fully Enumerable-compatible.
    
    See the unit and integration tests for details on usage.
    
    Inspired by Michael Grassotti's and Erick Tryzelaar's work at:
    
    * grasscode/tire@63fefb9
    * https://gist.github.com/2240721
    
    See the ElasticSearch documentation:
    
    * http://www.elasticsearch.org/guide/reference/api/search/search-type.html
    * http://www.elasticsearch.org/guide/reference/api/search/scroll.html
    
    Closes #196.
Commits on Mar 28, 2012
  1. Release 0.4.0

    karmi committed Mar 28, 2012
Commits on Mar 27, 2012
  1. Release 0.4.0.rc

    karmi committed Mar 27, 2012
  2. [#218] Fixed the incorrect serialization of `document_type` in Index#…

    sarmiena authored and karmi committed Mar 25, 2012
    …bulk_store
    
    Previously, when storing individual namespaced records, it correctly stored them as "my_namespace/my_model",
    but bulk_store was saving _type as "my_namespace%2Fmy_model".
    
    This resulted in two different document types where there should only be one, incorrect mapping, incorrect searches.
    
    Closes #290, closes #291, fixes #218.
  3. [FIX] Fixed displaying of Rake task usage

    karmi committed Mar 27, 2012
    (Let's all forget Rake actually works and makes sense as a Ruby library, shall we?)
Commits on Mar 26, 2012
  1. [#289] Update README and documentation, use the `prefix` query as the…

    karmi committed Mar 26, 2012
    … example of "unsupported" query
  2. [#289] Added an example of fuzzy query in the Text query integration …

    karmi committed Mar 26, 2012
    …test
    
    This is what you probably want to use when exposing the search interface to your users.
    
    See <http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html>
  3. [TEST] Improved code in the Text Query integration test

    karmi committed Mar 26, 2012
    Use regular Tire API, not custom RestClient calls...