Back to Jots

Determine your app’s Elasticsearch version

I often find myself searching for our Rails app’s Elasticsearch version. The exact Elasticsearch version is important as Elasticsearch’s API differs slightly from version to version.

If you’d like to quickly determine the version of your Elasticsearch instance, here’s how you can do it.

Open a rails console

bundle exec rails production console

If your Rails app uses the elasticsearch-model gem, run

version = Elasticsearch::Model.client.info["version"]["number"]
puts version

If your Rails app uses the tire gem, run

response = Tire::Configuration.client.get(Tire::Configuration.url)version = JSON.parse(response.body)
puts version

Alternatively, if you’ve SSH access to your Elasticsearch server or have SSH access from where you can reach Elasticsearch’s API, SSH in and hit Elasticsearch’s API

curl --silent -XGET http://localhost:9200 | python -c "import sys, json; print json.load(sys.stdin)['version']['number']"

As I mentioned earlier, Elasticsearch’s API differs from version to version. If you’re on MacOS, I found the Dash app to be very useful to quickly browse documentation of a specific Elasticsearch version.

Built with Hugo & Notion. Source code is available at GitHub.