chewy v0.7.0 Release Notes

Release Date: 2015-03-25 // about 9 years ago
  • ๐Ÿ’ฅ Breaking changes:

    • Chewy.use_after_commit_callbacks = false returns previous RDBMS behavior in tests

    • ActiveRecord import is now called after_commit instead of after_save and after_destroy

    • Import now respects default scope and removes unmatched documents

    • delete_from_index? method is deprecated, use

        define_type User, delete_if: ->{ removed? } do
          ...
        end
      
    • Chewy.request_strategy to configure action controller's request wrapping strategy

    • Chewy.root_strategy to configure the first strategy in stack

    • Default strategy for controller actions is :atomic

    • Default strategy for activerecord migrations is :bypass

    • Default strategy for sandbox console is :bypass

    • Default strategy for rails console is :urgent

    • Chewy.configuration was renamed to Chewy.settings

    • Reworked index update strategies implementation. Chewy.atomic and Chewy.urgent_update are now deprecated in favour of the new Chewy.strategy API.

    • Loading objects for object-sourced types using wrap method is deprecated, load_one method should be used instead. Or method name might be passed to define_type:

        class GeoData
          def self.get_data(elasticsearch_document)
            REDIS.get("geo_data_#{elasticsearch_document.id}")
          end
        end
      
        ...
          define_type GeoData, load_one_method: :get_data do
            ...
          end
      

    ๐Ÿ”„ Changes

    • Multiple enhancements by @DNNX

    • Added script_fields to search criteria (@ka8725)

    • ORM adapters now completely relies on the default scope. This means every scope or objects passed to import are merged with default scope so basically there is no need to define delete_if block. Default scope strongly restricts objects which may land in the current index.

        define_type Country.where("rating > 30") do
      
        end
      
        # this code would import only countries with rating between 30 and 50
        CountriesIndex::Country.import(Country.where("rating < 50"))
      
        # the same is true for arrays of objects or ids
        CountriesIndex::Country.import(Country.where("rating < 50").to_a)
        CountriesIndex::Country.import(Country.where("rating < 50").pluck(:id))
      
    • Object adapter supports custom initial import and load methods, so it could be configured to be used with procs or any class responding to call method.

        class GeoData
          def self.call
            REDIS.get_all
          end
        end
      
        ...
          define_type GeoData do
            ...
          end
      
    • Nested fields value procs additional arguments: parent objects.

        define_type Country do
          field :name
          field :cities do
            field :district, value: ->(city, country) { city.districts if country.main? }
          end
        end
      
    • Implemented basic named scopes

    ๐Ÿ›  Bugfixes

    • script_score allow options (@joeljunstrom)

    • Chewy indexes eaged loading fixes (@leemhenson)

    • Chewy::Index.import nil imports nothing instead of initial data