toptal/chewy
64.9
Adequate · 6 November 2026
8.7k
lines of production code
Ruby
primary language
4
measurements over time
What this system is
Features
Added Rails generator for Chewy configuration
Users can now use a Rails generator to install Chewy configuration. A new \InstallGenerator\ has been added to create a \config/chewy.yml\ file, which sets up separate Elasticsearch host configurations for the development (localhost:9200) and test (localhost:9250) environments.
lib/generators · high confidence
Introduce Delayed Sidekiq strategy for batched reindexing
Adds a new \DelayedSidekiq\ strategy that accumulates reindex requests in Redis over a configurable latency window and processes them in batches via Sidekiq workers. This change introduces three new files: \redis\_script.rb\ (a compatibility layer for running Lua scripts on both Sidekiq 6 and 7+ Redis clients), \scheduler.rb\ (which manages the accumulation of IDs and scheduling of batch jobs), and \worker.rb\ (which executes the batched reindexing). Users can now configure this strategy to reduce the overhead of frequent individual reindex operations by grouping them into time-chunked batches.
_lib/chewy/strategy/delayed\sidekiq · high confidence
New Minitest helpers for asserting and mocking Elasticsearch indexing
Added \Chewy::Minitest::Helpers\ and \SearchIndexReceiver\ to provide structured testing utilities for Chewy integration. Users can now use \assert\_indexes\ to verify that specific indices are updated during a code block, with the option to bypass actual HTTP calls to Elasticsearch. The helpers also include \mock\_elasticsearch\_response\ and \mock\_elasticsearch\_response\_sources\ to simulate Elasticsearch query results without a live server, and \assert\_elasticsearch\_query\ to validate rendered query structures. Additionally, \run\_indexing\ allows control over when indexing occurs, and \index\_everything!\ forces urgent indexing for all tests in a file.
lib/chewy/minitest · high confidence
New and reworked index update strategies for async and delayed processing
This change introduces several new indexing strategies and refactors existing ones to provide more flexible control over when and how Elasticsearch indices are updated. New strategies include \ActiveJob\ for asynchronous updates via Rails Active Job, \LazySidekiq\ for deferring callback evaluation until the end of a block using Sidekiq, \DelayedSidekiq\ for scheduling updates with a delay, and \AtomicNoRefresh\ for bulk imports without immediate index refresh. The existing \Sidekiq\ strategy is now configurable via a dedicated queue setting, and the \Urgent\ strategy is added for immediate, per-record updates. These changes allow users to choose the most appropriate synchronization method for their performance and consistency needs.
lib/chewy/strategy · high confidence
New parameter storage classes for Elasticsearch search options
The library introduces a comprehensive set of new parameter storage classes in \lib/chewy/search/parameters\ to support a wide range of Elasticsearch search features. These additions include storages for aggregations (\Aggs\), collapse (\Collapse\), KNN search (\Knn\), runtime mappings (\RuntimeMappings\), and docvalue fields (\DocvalueFields\). It also adds support for source filtering (\Source\), stored fields (\StoredFields\), and various boolean and integer parameters like \TrackTotalHits\, \MinScore\, \TerminateAfter\, and \RequestCache\. Furthermore, it implements storages for query components (\Query\, \Filter\, \PostFilter\), pagination (\Offset\, \Limit\), sorting (\Order\), and other request options such as \Highlight\, \Rescore\, \Suggest\, and \IndicesBoost\.
lib/chewy/search/parameters · high confidence
Removals
Removal of legacy Chewy::Type module files
The \lib/chewy/type\ directory has been cleaned up by deleting four legacy module files: \import.rb\, \mapping.rb\, \observe.rb\, and \wrapper.rb\. This removes the internal implementations for import logic, field mapping, ActiveRecord observation hooks, and attribute wrapping that were previously included in \Chewy::Type\. Users relying on these specific internal modules or any code explicitly requiring these files will need to update their dependencies or refactor to use the current Chewy API.
lib/chewy/type · high confidence
Behavioural changes
Chewy 8.4.1 release with major internal refactoring
This release updates the library version to 8.4.1 and introduces significant internal architectural changes. The legacy \Chewy::Query\ and \Chewy::Type\ classes have been removed in favor of a new \Chewy::Search\ module and a modular \Chewy::Index\ structure that includes dedicated modules for actions, aliases, import, mapping, and observation. A new \Chewy::ElasticClient\ wrapper has been added to manage Elasticsearch connections and explicitly close Faraday connections to prevent file descriptor leaks. The configuration system has been expanded with new options such as \use\_after\_commit\_callbacks\, \reset\_disable\_refresh\_interval\, and \before\_es\_request\_filter\. Additionally, new features include a \Chewy::MultiSearch\ interface for executing multiple queries via the Elasticsearch Multi Search API, a \Chewy::Journal\ class for applying and cleaning journal entries, and a \Chewy::Repository\ for managing analyzers and filters. The Rake helper has been updated to support these new capabilities, and the RSpec integration now includes helpers for building queries.
lib/chewy · high confidence
Enhanced RSpec matchers with atomic wrapping and strict filtering
The \update\_index\ RSpec matcher now defaults to wrapping index operations in an atomic strategy, ensuring that tests verify the final state of the index rather than intermediate bulk requests. It introduces an \.only\ chain method to enforce strict expectations, failing the test if any records are indexed or deleted beyond those explicitly specified via \and\_reindex\ or \and\_delete\. Additionally, the matcher now supports a \.no\_refresh\ chain to verify calls made with \refresh: false\, and includes new \build\_query\, \mock\_elasticsearch\_response\, and \mock\_elasticsearch\_response\_sources\ helpers to simplify query and response mocking in tests.
lib/chewy/rspec · high confidence
Kaminari pagination support moved to Search layer with new collection helper
Kaminari pagination integration has been relocated from the generic \Query\ class to the \Search::Request\ context, ensuring that pagination methods like \page\ and \per\ now apply specifically to search requests rather than all queries. The implementation now exposes a \paginated\_collection\ helper method, allowing users to easily convert raw result arrays into Kaminari-paginated collections with correct limit, offset, and total count metadata.
lib/chewy/search/pagination · high confidence
Major index architecture overhaul with compiled compose path and zero-downtime reset
The index module has been significantly restructured to improve performance and deployment safety. Document composition now defaults to a new compiled path that generates optimized Ruby methods at runtime, offering better performance than the legacy Witchcraft parser without requiring external AST dependencies. Index lifecycle management has been enhanced with new \create!\ and \delete!\ methods that support index suffixes for zero-downtime resets, allowing safe mapping changes without downtime. The import system now supports parallel processing, progress bars, and optional journaling for data consistency. Additionally, the library has dropped support for Elasticsearch 6.x, upgraded to Elasticsearch 8 client compatibility, and removed obsolete \\_type\ field references.
lib/chewy/index · high confidence
Major refactor of field composition and mapping generation
The field definition system has been significantly restructured to improve flexibility and correctness. Field initialization now uses keyword arguments, and the internal state management for options, children, and join-specific settings has been consolidated. The \compose\ method now supports passing multiple objects (including crutches and context) to value procs, enabling more dynamic data transformation. Mapping generation (\mappings\_hash\) has been rewritten to correctly handle nested fields, multi-fields, and default field types, ensuring proper Elasticsearch schema output. Additionally, the Root field now supports dynamic templates and explicit ID composition, allowing for more precise control over document indexing and JSON serialization.
lib/chewy/fields · high confidence
New and refactored Chewy rake tasks for index management
The \lib/tasks/chewy.rake\ file has been rewritten to provide a comprehensive set of Rake tasks for managing Elasticsearch indexes via the Chewy gem. This includes standard tasks for resetting, upgrading, updating, and synchronizing indexes, as well as a new \deploy\ task that combines upgrade and sync operations. A new \parallel\ namespace offers parallelized versions of these core tasks to improve performance, and a \journal\ namespace allows for manual journal creation, applying changes from a specific time, and cleaning up old journal records. The implementation delegates logic to \Chewy::RakeHelper\, supporting selective operations via command-line arguments.
lib/tasks · high confidence
New search DSL with dedicated parameter storages and loader
The search layer has been refactored to use a new DSL built around explicit parameter storages. \Chewy::Search::Parameters\ now manages request options (such as query, filter, limit, and offset) as distinct storage objects, allowing for more predictable merging and rendering of the Elasticsearch request body. \Chewy::Search::Request\ serves as the main entry point, delegating to these storages and exposing chainable methods for building queries. A new \Chewy::Search::Loader\ class handles the efficient loading of ORM/ODM objects from the database based on search hits, separating this concern from the request execution. Additionally, \Chewy::Search::Scrolling\ provides optimized batch iteration methods (\scroll\_batches\, \scroll\_objects\, etc.) that respect limits and properly clear scroll contexts, while \Chewy::Search::Response\ wraps the raw Elasticsearch response to provide convenient access to hits, wrappers, and loaded objects.
lib/chewy/search · high confidence
Project infrastructure modernized with RuboCop 1.84.2, Ruby 3.2+ target, and GitHub Actions CI
The repository has been updated to enforce modern code quality standards and CI practices. RuboCop has been upgraded to version 1.84.2, with a new \.rubocop.yml\ configuration targeting Ruby 3.2 and enabling the \rubocop-rake\ plugin. The continuous integration system has migrated from Travis CI to GitHub Actions, utilizing a Docker Compose setup to run Elasticsearch 8.19.13 and Redis 7 for testing. Additionally, legacy configuration files like \.travis.yml\ and \.rvmrc\ have been removed, and the project now requires Ruby \>= 3.2 and Rails \>= 7.2.
(repo-wide) · high confidence
Refactored core library structure and introduced runtime versioning
The library's internal structure has been significantly reorganized: the main entry point now explicitly requires specific Active Support extensions rather than the entire core\_ext bundle, and the monolithic type system has been replaced by a modular adapter-based architecture (Chewy::Index::Adapter). A new Chewy::Runtime::Version class has been added to handle semantic version comparison, and the global configuration storage has been migrated from fiber-local to thread-local variables via Chewy.current to better support multi-threaded environments. Additionally, the main module now exposes methods for managing Elasticsearch client lifecycle (close\_client) and cluster health (wait\_for\_status), while legacy error classes and the old derive\_type API have been removed in favor of the new derive\_name method.
lib · high confidence
Refactored import adapters with configurable scope cleanup
The import adapters for ActiveRecord and generic objects have been restructured into a new modular adapter hierarchy (Base, Orm, ActiveRecord, Object). A key behavioral change is that the cleanup of default index scope constraints (order, limit, offset) during import is now configurable via \Chewy.config.import\_scope\_cleanup\_behavior\, allowing users to choose between ignoring, warning, or raising an error when these constraints are present. The new ActiveRecord adapter implements batched importing and field plucking, while the Object adapter provides a generic fallback for non-ORM sources.
lib/chewy/index/adapter · high confidence
Refactored import engine with new bulk builder and progress bar
The import process has been restructured into dedicated components: BulkBuilder now handles the construction of Elasticsearch bulk requests (including join field support and partial updates), BulkRequest manages chunked transmission and error reporting, and JournalBuilder creates audit trail entries. A new Progressbar wrapper provides import feedback, addressing previous performance issues with parallel imports by ensuring the progress bar is only updated in the parent process. The Routine class orchestrates these components, supporting options like update\_fields, context passing, and failover logic.
lib/chewy/index/import · high confidence
Refactored parameter storage implementation with new type-specific concerns
The parameter storage system in \lib/chewy/search/parameters/concerns\ has been refactored to use distinct modules for different data types, replacing previous inheritance-based approaches. New storage concerns include \BoolStorage\ (which performs value disjunction on updates), \HashStorage\ (which merges hashes with stringified keys), \IntegerStorage\ and \StringStorage\ (which coerce values to their respective types), and \StringArrayStorage\ (which unions arrays). Additionally, \QueryStorage\ has been introduced to handle \query\, \filter\, and \post\_filter\ parameters using Elasticsearch's \bool\ query structure, supporting advanced operations like \must\, \should\, \must\_not\, \and\, \or\, and \minimum\_should\_match\. This change alters how search parameters are merged and updated, particularly for boolean and query-based filters.
lib/chewy/search/parameters/concerns · high confidence
Removal of legacy query criteria and Kaminari-based loading modules
The \Chewy::Query::Criteria\ class, which managed internal storage for search parameters like filters, facets, and sort, has been removed. Additionally, the \Chewy::Query::Loading\ module, which previously handled object loading by wrapping results in Kaminari's \PaginatableArray\, has been deleted. These changes indicate a shift away from the previous internal query structure and the Kaminari dependency for pagination within the query execution layer.
lib/chewy/query · high confidence
Test coverage
Added ActiveRecord test support and refactored class stubbing helpers; Added comprehensive test coverage for Chewy index internals; Added test coverage for Chewy index actions; Added test coverage for Chewy index adapters; Added test coverage for Chewy indexing strategies; Added test coverage for DelayedSidekiq strategy components; Added test coverage for Kaminari pagination integration; Added test coverage for Minitest integration helpers; Added test coverage for search parameter storage classes; Added test coverage for the import subsystem components; Added test coverage for the new Chewy search DSL components; Added tests for Chewy index observation and callback execution; Expanded RSpec matchers for index updates and query building; Expanded test coverage for Chewy core components; Expanded test coverage for Chewy field composition and root index behavior; Modernized test suite and added specs for client lifecycle and index management; Removed legacy Chewy query spec files; Removed legacy Chewy::Type module specs.
Dependencies
Add support for Rails 7.2, 8.0, and 8.1
The gemfiles now include dedicated configurations for testing against Rails 7.2, 8.0, and 8.1. These new gemfiles pull in the corresponding ActiveJob, ActiveRecord, and ActiveSupport versions. Notably, Rails 7.2 and 8.0 require pinning the \json\ gem to versions below 3 due to compatibility issues with \quirks\_mode\ in JSON generation, while Rails 8.1 does not have this constraint. A shared \base.gemfile\ is introduced to manage common development and testing dependencies like RSpec, RuboCop, and Sidekiq across all configurations.
gemfiles · high confidence
Upgrade to Elasticsearch 8 and Ruby 3.2+ requirements
This release updates the core dependency on the Elasticsearch client to version 8 (specifically \>= 8.14, \< 9.0) and raises the minimum required Ruby version to 3.2. The gemspec has been cleaned up with accurate metadata, and the main Gemfile now explicitly includes ActiveRecord, ActiveJob, and Ruby Progressbar while delegating test dependencies to a base gemfile.
(dependencies) · high confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 62 → 65 (+3.2)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.
Lenses
- Code Health 66 → 66 (+0.0)
- Architecture 88 → 86 (-1.5)
- Maturity 50 → 57 (+6.9)
- Readiness 73 → 73 (+0.0)
- Security 82 → 82 (+0.0)
Resolved (9)
- Documentation: no installation or build instructions (docs/testing.md)
- Documentation: no project overview (docs/testing.md)
- Duplicate intent across test helper modules. While technically distinct namespaces (RSpec vs Minitest), the method signatures and likely implementations are identical. This is a common pattern in Ruby gems, but strictly speaking, it represents duplicated API surface for the same testing utility.
- Inconsistent argument structure for equivalent operations. create takes (args, kwargs) while create! takes (suffix, options). This suggests a mismatch in how the underlying implementation handles parameters, or one is a legacy wrapper. Users cannot rely on a consistent signature pattern for the 'create' family of methods.
- Off-boarding risk: anonymized user #1
- Redundant naming convention for the same operation. In Ruby, the ! suffix typically denotes a 'dangerous' or 'bang' version that might raise errors or have side effects, but here both methods likely perform the same index creation logic. Without distinct behavioral differences documented, this creates API noise and confusion about which to use.
- Redundant naming convention. Same issue as delete/delete!. Two methods with identical signatures performing likely identical operations.
- Redundant naming convention. Similar to create/create!, having both delete and delete! with identical signatures (suffix) implies potential behavioral duplication without clear distinction in the signature itself.
- Signature asymmetry between test helpers. Minitest version accepts a block, while Rspec version does not. This forces users to adapt their test code differently depending on the framework, even though the intent is identical.
New (1)
- Off-boarding risk: anonymized user #1
Changes since last survey
- 7 commits — 7 feature/other, 0 fixes
By area
- .github/workflows — 6 commits
- lib/chewy — 1 commit
Notable commits
- change: Bump getplumber/plumber from 0.5.23 to 0.6.3 (#1068)
- change: Bump getplumber/plumber from 0.6.3 to 0.7.11 (#1071)
- change: Bump getplumber/plumber from 0.7.11 to 0.7.16 (#1074)
- change: Bump ruby/setup-ruby from 1.327.0 to 1.329.0 (#1069)
- change: Bump ruby/setup-ruby from 1.329.0 to 1.332.0 (#1072)
- change: Bump ruby/setup-ruby from 1.332.0 to 1.335.0 (#1073)
- change: Fix typos in code comments (#1070)
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
toptal/chewy was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 6 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit c0a9c0994cd9d33c381bd332ea68a45d2f49c0ab — the exact code this score is about.
- Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.2+preprod-5c4e66d9318b.