Skip to content
CAI
Software that uses CAICheck a score

elastic/elasticsearch-rails

57.7

Adequate · 19 September 2026

6.7k

lines of production code

Ruby

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is a suite of Ruby gems that integrates Elasticsearch with Ruby applications, providing model-level search capabilities and a repository pattern for data persistence. It supports multiple ORMs like ActiveRecord and Mongoid, enabling features such as automatic indexing, multi-model search, and pagination. The library also includes Rails-specific tools for data import tasks, logging instrumentation, and example applications to demonstrate usage.

How it got here

2013 — elasticsearch-model gem and adapter architecture

7 changes.

This period focused on the initial release and architectural restructuring of the elasticsearch-model gem, introducing a pluggable adapter system for ActiveRecord and Mongoid to support multi-model search and pagination. It also established new instrumentation, logging, and data import capabilities within elasticsearch-rails, while updating dependencies to require Ruby 3 and Elasticsearch 8.

2014 — elasticsearch-persistence release and examples

7 changes.

This period focused on the initial release of the elasticsearch-persistence gem, introducing a Repository pattern for managing Ruby domain objects in Elasticsearch. The work included refactoring the repository into modular components, updating version dependencies, and adding support for newer Elasticsearch response formats. Additionally, a suite of integration examples and a Sinatra demo application were created to demonstrate usage with various ORMs and data stores.

2018–2024 — RSpec migration and test expansion

14 changes.

This period focused on migrating the elasticsearch-model and elasticsearch-persistence test suites to RSpec, replacing previous testing frameworks with comprehensive new specifications. The work involved adding extensive coverage for core modules, adapters, and response handling, alongside integrating support for Rails 6.1 through 7.1.

Features

Initial release of elasticsearch-model gem with multi-model search and ORM adapters

This change introduces the \elasticsearch-model\ gem, providing integration between Ruby models (ActiveRecord, Mongoid) and Elasticsearch. It adds support for multi-model search, automatic index updates via callbacks, and pagination through Kaminari or WillPaginate. The implementation includes a proxy pattern to prevent namespace pollution and extends ActiveRecord's inspect method to handle missing database connections gracefully.

elasticsearch-model/lib/elasticsearch · high confidence

Initial release of elasticsearch-persistence gem

The elasticsearch-persistence gem is now available, providing a persistence layer for Ruby domain objects in Elasticsearch using the Repository pattern. This release includes the core Repository mixin for saving, finding, and searching objects, along with a DSL mixin for class-level configuration. The gem supports Elasticsearch 8.x and Ruby 3.1+, and includes comprehensive documentation, tests, and build infrastructure.

elasticsearch-persistence · high confidence

Introduce the elasticsearch-persistence gem entry point

The \elasticsearch-persistence\ gem is now available, providing a new entry point file that loads the core persistence components. This change enables users to utilize the Repository pattern for interacting with Elasticsearch by requiring the main library, which in turn loads the repository implementation, response result handling, and the gem's version information.

elasticsearch-persistence/lib/elasticsearch · high confidence

New Sinatra-based Notes example application

A new demo application named 'Notes' has been added to the \elasticsearch-persistence/examples\ directory. This Sinatra-based app demonstrates the repository pattern using \Elasticsearch::Persistence\, showing how to define a domain model, configure index mappings, and perform CRUD operations. It includes a full test suite and a \config.ru\ file for easy deployment.

elasticsearch-persistence/examples · high confidence

New instrumentation, logging, and import task components in elasticsearch-rails

This release introduces several new capabilities to the elasticsearch-rails gem (version 8.0.1). It adds an ActiveSupport instrumentation module that integrates with Rails logging to display Elasticsearch search durations in development logs and request breakdowns, including support for Lograge custom output. It also provides a new set of Rake tasks (\elasticsearch:import:model\ and \elasticsearch:import:all\) to facilitate importing data from ActiveRecord models into Elasticsearch, allowing for batch processing, scope filtering, and progress reporting.

elasticsearch-rails/lib/elasticsearch · high confidence

New integration examples for ActiveRecord, Mongoid, and other ORMs

Added a suite of runnable example scripts in the \elasticsearch-model/examples\ directory demonstrating how to integrate Elasticsearch with various Ruby data stores. The new files include \activerecord\_article.rb\ and \activerecord\_associations.rb\ for ActiveRecord (showing basic indexing and nested association mapping), \activerecord\_custom\_analyzer.rb\ for defining custom analyzers (pattern, trigram), \activerecord\_mapping\_completion.rb\ and \activerecord\_mapping\_edge\_ngram.rb\ for completion and autocomplete features, and standalone examples for Couchbase, DataMapper, Mongoid, Ohm, and Riak. These examples illustrate model setup, client configuration, indexing strategies, and search queries for each supported adapter.

elasticsearch-model/examples · high confidence

Architecture

Introduce adapter-based model integration with proxy isolation

The \elasticsearch-model\ gem has been restructured to use a pluggable adapter system (supporting ActiveRecord, Mongoid, and custom adapters) that handles database record fetching, callbacks, and bulk importing. Model interactions are now isolated via a \\_\elasticsearch\\_\ proxy to prevent namespace pollution, while new modules provide explicit control over index settings, mappings, document serialization, and client configuration.

elasticsearch-model/lib/elasticsearch/model · high confidence

Behavioural changes

The library introduces a modular adapter system in the \elasticsearch-model\ gem, replacing the previous monolithic implementation. This change adds dedicated adapters for ActiveRecord and Mongoid, enabling proper handling of model-specific features such as ActiveRecord 5+ sort order preservation, eager loading via the \:includes\ option, and efficient batch importing with \preprocess\ and \query\ support. It also introduces a \Multiple\ adapter that allows searching across different model types (e.g., mixing ActiveRecord and Mongoid models) in a single query, correctly deserializing and ordering results by type. A default adapter is provided for other ORM types, raising an error if specific methods are not implemented.

elasticsearch-model/lib/elasticsearch/model/adapters · high confidence

Rails application templates updated for Elasticsearch 7 and modern Rails

The example application templates (01-basic, 02-pretty, 03-expert, 04-dsl, 05-settings-files) have been updated to require Elasticsearch 7 or higher and Rails 5 or higher. The templates now automatically check for a running Elasticsearch cluster on startup and provide a Docker command to launch it if missing. The 'basic' template disables asset logging in development, uses the 'main' branch for gem dependencies, and includes a 'thin' gem for the server. The 'pretty' template adds Bootstrap styling, Kaminari pagination, and a custom search method with highlighting. The 'expert' template introduces a complex schema with categories, authors, and comments, uses Sidekiq for asynchronous indexing via Redis, and refactors Elasticsearch integration into a 'Searchable' concern. The 'dsl' template demonstrates using the elasticsearch-dsl gem for search definitions. The 'settings-files' template shows how to load index settings from an external JSON file.

elasticsearch-rails/lib/rails · high confidence

Refactored response handling and added pagination support

The response handling in the Elasticsearch model has been refactored to improve usability and compatibility. Search results are now wrapped in a \HashWrapper\ (based on \Hashie::Mash\) that allows direct access to document fields (e.g., \result.foo\ instead of \result.\_source.foo\) and fixes issues with \min\/\max\ methods conflicting with \Enumerable\. Pagination support has been added for both Kaminari and WillPaginate gems, allowing users to paginate search results using standard methods like \page\ and \per\_page\. Additionally, new methods \each\_with\_hit\ and \map\_with\_hit\ are available on records to yield both the record and its associated hit metadata.

elasticsearch-model/lib/elasticsearch/model/response · high confidence

Repository methods reorganized into modular components

The repository's functionality has been refactored into distinct modules (DSL, Find, Search, Serialize, Store) to improve code structure and maintainability. This change introduces a \count\ method for retrieving document counts, adds an \update\ method for partial document updates, and ensures that search and indexing operations correctly respect the \document\_type\ setting. Users will see these methods available on their repository classes, with the underlying implementation now split across specialized files for better clarity.

elasticsearch-persistence/lib/elasticsearch/persistence/repository · high confidence

Support for object-based total hits in search responses

The \Results\ class in the persistence repository now handles Elasticsearch search responses where the \total\ hits field is an object (containing a \value\ key) rather than a simple integer. This ensures that the \total\ method correctly extracts the hit count regardless of whether the response format uses a direct integer or an object wrapper, maintaining compatibility with newer Elasticsearch API versions.

elasticsearch-persistence/lib/elasticsearch/persistence/repository/response · high confidence

Test coverage

Added RSpec integration tests for the Mongoid adapter; Added RSpec test suite for Elasticsearch model adapters; Added RSpec test suite for instrumentation and logging integration; Added RSpec tests for ActiveRecord adapter integration; Added RSpec tests for Elasticsearch model response components; Added RSpec tests for Kaminari and WillPaginate pagination integration; Added test coverage for repository persistence operations; Added test suite for Elasticsearch Persistence Repository; Added test support fixtures for elasticsearch-model; Added tests for Elasticsearch::Persistence::Repository::Response::Results; Added tests for LogSubscriber color formatting; Migrate elasticsearch-model test suite to RSpec; Ported elasticsearch-model unit tests to RSpec.

Dependencies

Added gemfiles for Rails 6.1, 7.0, and 7.1 testing

New Bundler gemfiles have been added to the elasticsearch-model gemfiles directory to support integration testing against Rails 6.1, 7.0, and 7.1. These files configure the appropriate activemodel and activerecord versions for each target, along with sqlite3 and development/testing dependencies like debug, pry-nav, and rspec, enabling the project to verify compatibility with these specific Rails versions.

elasticsearch-model/gemfiles · high confidence

Elasticsearch Persistence gem updated to version 8.0.1

The elasticsearch-persistence gem has been updated to version 8.0.1. This release includes the Repository mixin module, which provides core functionality for interacting with Elasticsearch indices, including methods for creating repositories, managing index names, clients, mappings, and settings, as well as integrating with the Elasticsearch::Model indexing capabilities.

elasticsearch-persistence/lib/elasticsearch/persistence · high confidence

Ruby 3 support and Elasticsearch 8 client dependency

The elasticsearch-rails gem suite (including elasticsearch-model and elasticsearch-persistence) now requires Ruby 3 or higher and depends on the elasticsearch gem version 8. This shift aligns the Rails integrations with the latest Elasticsearch Ruby client, replacing the older transport layer and dropping support for Ruby versions below 3.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 58.

Lenses

  • Code Health 99
  • Architecture 88
  • Maturity 47
  • Readiness 66
  • Security 90
  • Domain Modelling 100
  • Accessibility 52

Changes since last survey

  • 300 commits — 269 feature/other, 31 fixes

By area

  • (root) — 73 commits
  • elasticsearch-model/lib — 48 commits
  • elasticsearch-model/spec — 32 commits
  • .github/workflows — 16 commits
  • elasticsearch-rails/lib — 16 commits
  • elasticsearch-model/README.md — 15 commits
  • elasticsearch-model/examples — 14 commits
  • elasticsearch-persistence/lib — 14 commits
  • elasticsearch-model/test — 12 commits
  • elasticsearch-persistence/README.md — 7 commits
  • elasticsearch-persistence/elasticsearch-persistence.gemspec — 7 commits
  • elasticsearch-model/Rakefile — 6 commits
  • elasticsearch-model/gemfiles — 6 commits
  • elasticsearch-persistence/examples — 6 commits
  • elasticsearch-model/elasticsearch-model.gemspec — 5 commits
  • elasticsearch-persistence/spec — 4 commits
  • elasticsearch-persistence/test — 4 commits
  • elasticsearch-rails/spec — 4 commits
  • .github/check-license-headers.sh — 2 commits
  • .github/stale.yml — 2 commits

Notable commits

  • fix: Fix Elasticsearch-model README typo under Importing the Data (#565)
  • fix: Fix Travis before script
  • fix: Fix missing environment dependency for import tasks
  • fix: Fix multi_model_spec
  • fix: Fix sort order on ActiveRecord >= 5. re issue #546 (#831)
  • fix: Fix specs to include body in spec_helper
  • fix: Fix/cleanup Rakefile
  • fix: Fixed Dup on ES Aggregations
  • fix: Fixed the incorrect links to Travis and CodeClimate in the main README
  • fix: Fixes basic template elasticsearch dependency
  • fix: Fixes some styling in Rakefile
  • fix: Updates elasticsearch-model rake task, fixes dependencies
  • fix: Whitespace fixes
  • fix: [DOCS] Updates Readme Fixes #925
  • fix: [MODEL] Fix Asynchronous Callbacks example
  • fix: [MODEL] Fix import method to pass index name on refresh (#692)
  • fix: [MODEL] Fix import when preprocess returns empty collection (#720)
  • fix: [MODEL] Fix reference to @ids in example and README
  • fix: [MODEL] Fixed incorrect mapping configuration in the integration tests
  • fix: [MODEL] Fixed incorrect name for the parent/child integration test
  • …and 280 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

elastic/elasticsearch-rails 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 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 41f4291407f4cd1b9f2c2b574e05853920086955 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.