ActiveRecord integration for Esse. Provides:
collection ModelDSL for repositories, backed byfind_in_batches.- Automatic
after_commitcallbacks to index, update, or delete documents. - Scoping and per-batch context fetching for efficient serialization.
- Hook-based control to disable indexing globally, per-repository, or per-model.
- Support for partial
:updateand lazy attribute denormalization.
Contents
Quick start
# Gemfilegem 'esse-active_record'class UsersIndex < Esse::Index plugin :active_record
repository :user do collection ::User, batch_size: 500 do scope :active, -> { where(active: true) } end
document do |user, **| { _id: user.id, name: user.name, email: user.email } end endendclass User < ApplicationRecord include Esse::ActiveRecord::Model index_callback 'users_index:user'endEvery User.create!, update!, and destroy now syncs to Elasticsearch automatically.
Version
- Version: 0.3.9
- Ruby:
>= 2.4.0 - Depends on:
esse >= 0.3.0,esse-hooks,activerecord >= 4.2
License
MIT.