Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Rebase to lastest upstream #1

Open
wants to merge 71 commits into
base: master
Choose a base branch
from
Open

Rebase to lastest upstream #1

wants to merge 71 commits into from

Conversation

me
Copy link

@me me commented Feb 3, 2014

Because search needs the suggest functionality, that's not available in the version we are currently using.

Rubberband tests pass, not sure how to run Tire's own tests though.

karmi and others added 30 commits June 3, 2013 18:34
`bundle exec rake environment tire:import:all` now succeeds for a `Address` model.

Fix provided by @congshuanglong.

Closes karmi#733, closes karmi#744
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 karmi#701
…tured 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: karmi#734
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: karmi#734
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 karmi#709
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 karmi#716
Previously, `to_hash` method was checked, but not called on the params object
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 karmi#724
* 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 karmi#724

Cc: @tobycox
…lection

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

Fixes: karmi#724
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 karmi#708
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 <karmi#31 (comment)>

Closes karmi#663, closes karmi#687, closes karmi#712
…_elasticsearch_index

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

Closes karmi#729
* Type is an optional argument
* IDs argument is converted to Array

Closes karmi#751
Filters are automatically wrapped by `:and`

Closes karmi#715
phungleson and others added 30 commits October 2, 2013 14:16
When loading environment berfor tire:import:all, it is possible that
models are already loaded when tire tries to load them. This can cause
redefinition of constants and all other kind of havoc.

This fix first tries to constantize the models to see if they are
already loaded before trying to require them.

See issue karmi#744 for discussion.

Closes karmi#869
Kaminari's method is called "out_of_range?", but tire uses "out_of_bounds?". I added the alias to make integration with Kaminari easier.

Closes karmi#855
    # update mapping
    index = Tire::Index.new(Contact.tire.index_name)
    puts index.mapping(
      Contact.tire.document_type,
      properties: {
        updated_at: {
          type: 'date',
          format: 'date_time_no_millis'
        }
      }
    )

    # add data
    Contact.find_in_batches do |batch|
      documents = batch.map do |contact|
        {
          id: contact.id,
          type: Contact.tire.document_type,
          _routing: contact.account_id,
          doc: ContactSearchSerializer.new(contact, only: :updated_at).as_json
        }
      end
      puts index.bulk_update(documents)
    end

Closes karmi#853
…e `response` method on return value

Similarly to what is available in the persistent storage class.

Closes karmi#908
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.