// the find
elastic/elasticsearch-rails
Elasticsearch integrations for ActiveModel/Record and Ruby on Rails
Official Elastic-maintained gem that wires Elasticsearch into ActiveRecord and Mongoid models via mixins. You include the module, call import, and your model gets a search class method that returns result objects wrapping ES hits. Aimed at Rails apps that want search without a separate search service.
The ActiveRecord adapter is genuinely well thought out — bulk import batches correctly, the callbacks module hooks after_commit not after_save, so partial transactions don't cause phantom index updates. Response objects implement Enumerable and play nicely with both Kaminari and WillPaginate without you doing anything. The instrumentation hooks into Rails' AS::Notifications so search queries show up in your logs and in tools like Skylight automatically. Multiple sub-gems with clean separation means you can use just the model integration without pulling in the persistence layer.
The gem version is pinned to ES major versions (8.x gem → ES 8.x), which sounds disciplined but has burned people on minor version gaps where the client behavior changed. The `include Elasticsearch::Model::Callbacks` approach synchronously indexes on every save by default — there's no built-in async indexing story, so any Rails app with real write volume will need to bolt on Sidekiq themselves. The persistence repository pattern is underdocumented and feels half-baked compared to the model integration; the example app uses 7.6.0 Docker image in the README despite the gem targeting 8.x. No support for Elastic's newer features like semantic search or ELSER out of the box.