CLI

Esse ships with a Thor-based CLI called esse. It handles scaffolding, index lifecycle, and bulk operations.

Running

Terminal window
bundle exec esse <command> [options]

Or as a standalone executable:

Terminal window
gem install esse
esse <command>

Global options

FlagDescription
--require FILE, -r FILERequire a file before executing (useful for a custom config)
--silent, -sSuppress event output
--version, -vPrint version
--helpPrint help

Configuration paths

The CLI auto-loads the first existing file from:

  1. Essefile
  2. config/esse.rb
  3. config/initializers/esse.rb

In a Rails app, add require 'esse/rails' (via the esse-rails gem) and the Rails environment is loaded automatically.

Commands

esse install

Generate a configuration file template:

Terminal window
bundle exec esse install
bundle exec esse install --path config/my_esse.rb

Options:

FlagDefaultDescription
--path / -pconfig/esse.rbTarget path

esse generate index <CLASS_NAME>

Scaffold a new index class:

Terminal window
bundle exec esse generate index UsersIndex

Creates app/indices/users_index.rb (or wherever Esse.config.indices_directory points) with a template.


esse index reset <INDEX_CLASS>

Zero-downtime index reset — create a new concrete index, import data, swap the alias, and remove the old one.

Terminal window
bundle exec esse index reset UsersIndex --suffix 20240401 --optimize
OptionDefaultDescription
--suffixtimestampConcrete index suffix
--importtrueImport from collection
--reindexfalseUse ES _reindex API instead of importing
--optimizetrueTemporarily drop replicas/refresh for faster bulk
--settingsJSON/hash to override index settings
--preload_lazy_attributesPreload lazy attributes via search before import
--eager_load_lazy_attributesResolve lazy attributes during bulk
--update_lazy_attributesPartial-update lazy attributes after bulk

esse index create <INDEX_CLASS>

Create an index without importing:

Terminal window
bundle exec esse index create UsersIndex --alias
OptionDefaultDescription
--suffixConcrete suffix
--aliasfalseAlso create the alias pointing at the index
--settingsOverride settings

esse index delete <INDEX_CLASS>

Terminal window
bundle exec esse index delete UsersIndex --suffix 20240401

esse index import <INDEX_CLASS>

Terminal window
bundle exec esse index import UsersIndex \
--repo user \
--context active:true,region:us \
--suffix 20240401
OptionDescription
--repoSpecific repository (omit to import all)
--suffixTarget index suffix
--contextContext hash for collection filtering
--preload_lazy_attributesPreload via search
--eager_load_lazy_attributesResolve during bulk
--update_lazy_attributesRefresh as partial updates

esse index open <INDEX_CLASS> / esse index close <INDEX_CLASS>

Open or close the index:

Terminal window
bundle exec esse index close UsersIndex
bundle exec esse index open UsersIndex

esse index update_aliases <INDEX_CLASS>

Point the alias at one or more concrete indices:

Terminal window
bundle exec esse index update_aliases UsersIndex --suffix 20240401
bundle exec esse index update_aliases UsersIndex --suffix v1,v2

esse index update_settings <INDEX_CLASS>

Terminal window
bundle exec esse index update_settings UsersIndex --settings number_of_replicas:2

esse index update_mapping <INDEX_CLASS>

Terminal window
bundle exec esse index update_mapping UsersIndex
bundle exec esse index update_mapping UsersIndex --suffix 20240401

esse index update_lazy_attributes <INDEX_CLASS> <attr> [attr ...]

Refresh specific lazy attributes without a full reindex:

Terminal window
bundle exec esse index update_lazy_attributes UsersIndex comment_count follower_count \
--repo user \
--context active:true
OptionDescription
--repoRepository name (required when multiple)
--suffixTarget suffix
--contextCollection context
--bulk_optionsExtra ES bulk options

Extension commands

Gems like esse-async_indexing add more subcommands:

Terminal window
bundle exec esse index async_import UsersIndex --service sidekiq
bundle exec esse index async_update_lazy_attributes UsersIndex comment_count --service sidekiq

Consult each extension’s documentation for details.

Exit codes

  • 0 — success
  • non-zero — any error

Use --silent in CI to reduce noise.

Example workflows

First-time bootstrap

Terminal window
bundle exec esse install
# edit config/esse.rb
bundle exec esse generate index UsersIndex
# edit app/indices/users_index.rb
bundle exec esse index reset UsersIndex

Daily reindex via cron

Terminal window
bundle exec esse index reset UsersIndex --suffix $(date +%Y%m%d) --optimize

Partial refresh

Terminal window
bundle exec esse index update_lazy_attributes UsersIndex comment_count