Release v0.5.8

Fixes: #688
[FIX] Fixed incorrect filename to class inflection in Rake import task

`bundle exec rake environment tire:import:all` now succeeds for a `Address` model.

Fix provided by @congshuanglong.

Closes #733, closes #744
Added support for `geo_distance` facets

Usage:

Tire.search 'venues' do
  query { string 'pizzeria' }

  facet 'geo' do
    geo_distance :location,
                 {:lat => 53.54507, :lon => 9.95309},
                 [{:to => 1}, {:from => 1, :to => 10}, {:from => 50}],
                 unit: 'km'
  end
end

Closes #701
Added support for the `custom_filters_score` query

Closes #734
[#734] Added DSL versions for `custom_filters_score` and restructured the source code

Allow the DSL version of filters definition:

    s = Tire.search('articles-test') do
      query do
        custom_filters_score do
          query { all }

          # Give documents over 300 words a score of 3
          filter do
            filter :range, words: { gt: 300 }
            boost 3
          end
        end
      end
    end

Related: #734
[#734] Added the `custom_filters_score` query from Tire contrib

As a replacement for the `custom_filters_score` query added
in previous commits, a more feature-complete implementation
by @jerryluk from karmi/tire-contrib has been added.

Fixes: #734
Added a custom strategy option to <Model.import>

Sometimes, when you have a complicated ActiveRecord relationships,
you need tight control on the importing SQL queries and mechanics.

This patch allows you to implement your own custom strategy, by
implementing an `import` method, and passing it to <Model.import>
as the `:strategy` option.

Example:

class MyCustomImportStrategy
  include Base
  def import &block
    klass.
      where(published: true).
      joins(:comments).
      find_in_batches(:batch_size => options[:per_page]) do |batch|
        index.import batch, options, &block
      end
    self
  end
end

Closes #709
[FIX] Make Tire::Results::Collection#to_ary return an Array

Closes #718, closes #432
Allow the `:wrapper` option to be passed to Tire.search consistently

Example:

    s = Tire.search 'articles-test', wrapper: ::MyCustomWrapper do
      query { match :title, 'one' }
    end

    s = Tire.search(
      'articles-test',
      payload: { query: { match: { title: 'one' } } },
      wrapper: ::MyCustomWrapper
    )

Closes #716
Added conversion of params object to Hash in <Tire.search>

Previously, `to_hash` method was checked, but not called on the params object
Changed, that Mongoid cursor is used for import, avoiding `skip()`

Iterating through mongoid collections using skip() can get really slow for large collections, as it has to traverse from the beginning of the collection (http://docs.mongodb.org/manual/reference/method/cursor.skip/).

We were seeing our import task freeze up with high I/O after importing around 2.5 million records in a 6 million record collection.

This commit alters the Mongoid import task so that it batches manually and makes the use of Mongoid's cursor to only return a small batch of results.

Closes #724
[#724] Fix incorrect Mongoid import strategy

* For collections less then :per_page, no data would be imported.
* For a collection of 1,200 items, the last 200 documents won't be imported for the default batch of 1,000

Fixes #724

Cc: @tobycox
[#724] Use modulo in Mongoid import strategy for breaking up collection

In Mongoid import strategy, use the modulo division for better semantics
of breaking up the collection into batches.

Fixes: #724
Removed the auto-loading of Rails' `environment` task

As reported by some users, the auto-loading didn't invoked/executed the task properly,
resulting in errors eg. due to not loaded initializers.

The auto-invoking has been removed, since the documentation clearly states
to invoke the task before the importing one.

Closes #708
[FIX] Merge returned `fields` with `_source` if both are returned

Previously, when asking for `_source` in `fields`, only the specific `fields`
have been returned, not the full _source.

The Elasticsearch behaviour has possibly changed here,
see <https://github.com/karmi/tire/pull/31#issuecomment-1340967>

Closes #663, closes #687, closes #712
[TEST] Added a unit test for using `_source` in conjunction with `fields`

Related: #663, #687 #712
[TEST] Added an integration test for fields / script fields / _source

Related: #663, #687 #712
[¡BREAKING!] Removed the deprecated `text` query
[FIX] Rescue HTTP client specific connection errors in MyModel#create_elasticsearch_index

Added a `__host_unreachable_exceptions` for each HTTP client (adapter), so we can
rescue connection related errors in `create_elasticsearch_index`.

Closes #729
Added support for passing `version` in Tire::Index#store

Closes #699