Permalink
Commits on Jul 25, 2012
  1. [FIX] Fixed errors in the "terms" facet on Ruby 1.8

    In Ruby 1.8.x:
    
        "hello".is_a?(Enumerable)
        # => true
    
        "hello".respond_to?(:each)
        # => true
    
    Can be confusing, yeah. You should upgrade to 1.9 :)
    karmi committed Jul 25, 2012
  2. [#300] Added DisMaxQuery#to_json

    Closes #415.
    nbudin committed with karmi Jul 25, 2012
  3. [#300] Added an example for "Dis Max Query" based on elasticsearch do…

    …cumentation
    
    NOTE: The dis_max query gives exactly the same result as a boolean query:
    
        boolean = Tire.search 'dis_max_test' do
          query do
            boolean do
              should { string "albino",   fields: ['title', 'text'] }
              should { string "elephant", fields: ['title', 'text'] }
            end
          end
        end
    
    This seems to contradict <http://www.elasticsearch.org/guide/reference/query-dsl/dis-max-query.html>?
    
    > We want the primary score to be the one associated with the highest boost,
    > not the sum of the field scores (as Boolean Query would give).
    > If the query is “albino elephant” this ensures that “albino” matching one field
    > and “elephant” matching another gets a higher score than “albino” matching both fields.
    karmi committed Jul 25, 2012
  4. [#300] Added the "Dis Max Query"

    Usage:
    
    Tire.search 'index' do
      query do
        dis_max do
          query { string 'foo' }
          query { terms :tags, ['baz'] }
        end
      end
    end
    
    See http://www.elasticsearch.org/guide/reference/query-dsl/dis-max-query.html
    
    Closes #300.
    hajder committed with karmi Apr 3, 2012
Commits on Jul 23, 2012
  1. Fix typo (s/operation/operating/) system

    Closes #412
    Rich Healey committed with karmi Jul 22, 2012
Commits on Jul 13, 2012
  1. [CI] Added running functional tests against live elasticsearch at Tra…

    …vis CI [http://travis-ci.org/#!/karmi/tire]
    
    Squashed from the `karmi/tire@travis` branch:
    
    c2d7f0d ‣ Restructuring the Travis configuration
    79f454d ‣ Added running integration tests against live elasticsearch on Travis
    d1c4374 ‣ Allow build failures on 1.8.7 and REE
    b4fa8a0 ‣ Changed, that integration tests are run only on Ruby 1.9, unit tests on all Rubies
    karmi committed Jun 25, 2012
  2. [FIX] Fixes Ruby 1.8.7 incompatibility

    * Fixes karmi/retire@6c3b852 by @karmi (incorrect trailing dot)
    * Fixes karmi/retire@ce47d00 by @karmi (Hash order)
    karmi committed Jul 13, 2012
  3. [ACTIVEMODEL] Allow to pass :version option in Tire::Model::Search::C…

    …lassMethods#search
    karmi committed Jul 13, 2012
Commits on Jul 12, 2012
Commits on Jul 11, 2012
  1. [FIX] Fixed incorrect `Results::Item#to_hash` serialization

    Without this fix, `Item#to_hash` returned `Item` instances for nested Hashes.
    
    This commit calls `to_hash` recursively in `Item#to_hash`
    karmi committed Jul 11, 2012
Commits on Jun 25, 2012
  1. [TESTS] Fixed errors on Ruby 1.8

    * Changed Ruby 1.9 hashes to hashrocket syntax
    * Changed regex to allow different URL parts order
    karmi committed Jun 25, 2012
  2. Patch Test::Unit::Assertion#assert on Ruby 1.8 to return true on success

    Our Mocha `with do ... end` blocks fail otherwise.
    karmi committed Jun 25, 2012
Commits on Jun 24, 2012
  1. [#366] Cleaned up the Update API support and added an integration tes…

    …t suite
    
    This patch expands karmi/retire@f620b36.
    
    * Polished the `curl` output from the API call
    * Added the ability to pass URL parameters (timeout, refresh, etc)
    * Cleaned up the unit tests
    * Added a separate integration test for resilience and documentation
    
    Example usage
    -------------
    
    Update a counter:
    
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ruby
      Tire.index('articles-with-tags') { update( 'article', '1', :script => "ctx._source.views += 1" ) and refresh }
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Add a tag to the document:
    
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ruby
        Tire.index('articles-with-tags') do
          update 'article', '1', :script => "ctx._source.tags += tag",
                                 :params => { :tag => 'new-tag' }
          refresh
        end
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Set a title of the document:
    
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ruby
      @title = 'Foo Is Now Bar!'
    
      Tire.index('articles-with-tags') do |index|
    
        index.update 'article', '1', :script => "ctx._source.title = title",
                                     :params => { :title => @title }
        index.refresh
      end
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    See <http://www.elasticsearch.org/guide/reference/api/update.html> for more documentation.
    
    ---
    
    Closes #366.
    karmi committed Jun 24, 2012
  2. [#366] Added support for the Update API in Tire::Index

    Usage:
    
        tags = ['a', 'b', 'c']
    
        Tire.index 'my_index' do
          update 'document_type', 'document_id', {
            :script => "_ctx._source.tags = tags;',
            :params => {:tags => tags}
          }
        end
    ahfeel committed with karmi Jun 4, 2012
Commits on Jun 20, 2012
  1. [#352] Added MyModel#new_record? for Tire::Persistence

    Commit <erickt@40cb975> rewritten and cleaned up by @karmi
    erickt committed with karmi Apr 27, 2012
  2. [#352] Added, that accessing Tire::Search#json forces perform

    Conflicts:
    
    	lib/tire/search.rb
    erickt committed with karmi May 8, 2012
Commits on Jun 18, 2012
  1. Added that MyModel#all is called in Rake import task

    Closes #380, closes #381.
    cseeger committed with karmi Jun 17, 2012
  2. Added, that boost factor can be specified for indices

    Example:
    
        Tire.search 'index_1' => { boost: 1.5 }, 'index_2' => { boost: 2 } do
          ...
        end
    
    Closes #205, closes #377.
    andruby committed with karmi Jun 16, 2012
Commits on Jun 10, 2012
Commits on Jun 9, 2012
  1. Added a Faraday adapter as a Tire client

    NOTE: As soon as possible, Tire will try to use Faraday as HTTP abstraction layer.
          This client is a temporary solution.
    
    Closes #337.
    romanbsd committed with karmi May 7, 2012
Commits on Jun 8, 2012
  1. Added tests for the "Include the response code in the log for bulk_st…

    …ore requests" patch
    karmi committed Jun 8, 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…

    … 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.
    karmi committed May 2, 2012
  3. [FIX] Fixed, that blocks passed to `Tire::Index.new` or `Tire.index` …

    …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.
    karmi committed May 4, 2012
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

    Closes #328, fixes #327
    nz committed with karmi Apr 30, 2012