Desi (Developper Elasticsearch Installer) is very simple tool to quickly set up an Elastic Search local install for development purposes.
- download and install Elasticsearch (the latest release by default)
- start/stop/restart it.
- do basic indices management (list, delete, empty a given set of indices)
It can be used both as a command-line tool and as a library.
$ desi list # List locally installed Elasticsearch releases $ desi releases # List all upstream Elastic Search releases (latest 5 by default) $ desi install [VERSION] # Install a specific version (latest by default) $ desi start # Start a local 1-node cluster (noop if active) $ desi restart # (Re)start cluster (even if active) $ desi stop # Stop cluster $ desi status [--host HOST] # Show running cluster info $ desi tail # Show tail output from Elastic Search's log file $ desi indices "^foo" # List all indices whose name match /^foo/ $ desi indices "^foo" --delete # Delete all matching indices $ desi indices "bar$" --empty # Remove all records from the matching indices
$ # The latest version will be installed by default $ desi install * No release specified, will fetch latest. * fetching release elasticsearch-1.0.1.tar.gz […] $ # You can also give a specific release name $ desi install 0.90.12 # ("v0.90.12" or "elasticsearch-0.90.12" would also work) * fetching release elasticsearch-0.90.12.tar.gz […]
The current version is the one symlinked to
will be spun up by (
$ desi list Local ES installs in /home/me/elasticsearch (current one is tagged with '*'): * elasticsearch-1.0.1 (/home/me/elasticsearch/elasticsearch-1.0.1) - elasticsearch-1.0.0 (/home/me/elasticsearch/elasticsearch-1.0.0)
Desi::LocalInstall.new.releases.map(&:name) #=> ["elasticsearch-1.0.0", "elasticsearch-1.0.1"] Desi::LocalInstall.new.releases.detect(&:current?).version #=> "1.0.1"
$ desi start * Elastic Search 1.0.1 started $ desi status OK. Elastic Search cluster 'elasticsearch' (v1.0.1) is running on 1 node(s) with status yellow # Start Elastic Search in the foreground $ desi start -f # or --foreground ES will be launched in the foreground ^C # Manual stop with Control-C Elastic Search interrupted!
Desi::ProcessManager.new.start.status #=> "OK. Elastic Search cluster 'elasticsearch' (v1.0.1) is running on 1 node(s) with status green"
$ # List all local indices $ desi indices Indices from host http://127.0.0.1:9200 matching the pattern /.*/ foo bar baz $ # List all indices with "foo" in their name on remote cluster 22.214.171.124, port 9800 $ desi indices --host 126.96.36.199:9800 foo Indices from host http://192.168.1.42:9800 matching the pattern /foo/ remotefoo1 remotefoo2 $ # Remove all indices whose name starts with "ba" $ desi indices --delete "^ba" The following indices from host http://127.0.0.1:9200 are now deleted * bar * baz
# All local indices Desi::IndexManager.new.list #=> ["foo", "bar", "baz"] # All local indices whose name starts with "b" Desi::IndexManager.new.list("^b") #=> ["bar", "baz"] # All indices from distant cluster Desi::IndexManager.new(host: "192.168.1.42:9800").list #=> ["remotefoo1", "remotefoo2"] # Delete all local indices whose name starts with "ba" Desi::IndexManager.new.delete!("^ba") #=> nil # The indices actually disappeared! \o/ Desi::IndexManager.new.list #=> ["foo"]
There are two settings at the moment: location of the installation directory
~/elasticsearch) and ES host address (
Desi will look for files
~/.desi.yml (the options found in
the former will be overriden by the ones found in the latter).
echo -e "---\n directory: ~/foobar" > ~/.desi.ymlfor instance
Desi.configure do |c| c.directory = "~/local/foo" c.server = "192.168.1.42:9200" end
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install desi
add more tests
desi upgrade(Upgrade to latest version and migrate data)
desi switch VERSION(Switch currently active ES version to VERSION)
- plugin management ? (list, install, remove ES plugins)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request